struct

passing an array structure as an array

I'm having trouble passing a structure array as a parameter of a function struct Estructure{ int a; int b; }; and a funtion Begining(Estructure &s1[]) { //modifi the estructure s1 }; and the main would be something like this int main() { Estructure m[200]; Begining(m); }; is this valid? ...

Is it a good practice to pass struct object as parameter to a function in c++?

I tried an example live below: typedef struct point { int x; int y; } point; void cp(point p) { cout<<p.x<<endl; cout<<p.y<<endl; } int main() { point p1; p1.x=1; p1.y=2; cp(p1); } The result thats printed out is: 1 2 which is what I expected. My que...

C++ struct sorting error

I am trying to sort a vector of custom struct in C++ struct Book{ public:int H,W,V,i; }; with a simple functor class CompareHeight { public: int operator() (Book lhs,Book rhs) { return lhs.H-rhs.H; } }; when trying : vector<Book> books(X); ..... sort(books.begin(),books.end(), CompareHeight()); it gives me e...

How to extract ALL typedefs and structs and unions from c++ source

I have inherited a Visual Studio project that contains hundreds of files. I would like to extract all the typedefs, structs and unions from each .h/.cpp file and put the results in a file). Each typdef/struct/union should be on one line in the results file. This would make sorting much easier. typdef int myType; struct myFirstStruc...

Declaring struct in header file

I've been trying to include a structure called "student" in a student.h file, but I'm not quite sure how to do it. My student.h file code consists of entirely: #include<string> using namespace std; struct Student; while the student.cpp file consists of entirely: #include<string> using namespace std; struct Student { string las...

How do I rename a field in a structure array in MATLAB?

Given a structure array, how do I rename a field? For example, given the following, how do I change "bar" to "baz". clear a(1).foo = 1; a(1).bar = 'one'; a(2).foo = 2; a(2).bar = 'two'; a(3).foo = 3; a(3).bar = 'three'; disp(a) What is the best method, where "best" is a balance of performance, clarity, and generality? ...

float** allocation limit + serialized struct problem. Need advice!

basically im getting an allocation limit error/warning when i create a float** array. the function i am calling to fill the float** retrieves data from a struct loaded from a file. The function works fine when i use one object but when i load 2 objects into memory i get the limit error. I am pretty sure this is to do with byte alignment ...

segfault on vector<struct>

Hello, I created a struct to hold some data and then declared a vector to hold that struct. But when I do a push_back I get damn segfault and I have no idea why! My struct is defines as: typedef struct Group { int codigo; string name; int deleted; int printers; int subpage; /*included this when it started seg...

How can I store an inventory-like list of numbers?

I've got a list of number that I need to keep track of. The numbers are loosely related, but represent distinctly different items. I'd like to keep a list of the numbers but be able to refer to them by name so that I can call them and use them where needed easily. Kind of like an inventory listing, where the numbers all refer to a part I...

Can we pass a whole Structure over an URL ?

Hi, I am opening a new popup window on click of an URL in my page. My question over here is Can i pass whole structure to the new page ? If thats not possible is there any simple method to do that ? ...

Data Types and Structs

I'm reviewing for a test, and I am stumped by this question. Consider the following declarations: enum CategoryType {HUMANITIES, SOCIALSCIENCE, NATURALSCIENCE}; const int NUMCOURSES = 100; struct CourseRec { string courseName; int courseNum; CategoryType courseCategory; }; typedef CourseRec CourseLis...

c# pinvoke marshall struct

Hi, I have an unmanaged struct I'd like to marshal to c# that looks basically like this: struct DateTimeStruct{ double datetimestamp; }; struct MyStruct{ char firstname[40]; char lastname[40]; DateTimeStruct bday; unsigned integer bool1; int val1; }; What is the the correct c# declaration? ...

iPhone App/Java Server Struct Data Issue over WiFi

I currently have an iPhone app that communicates with a C++ server running on a computer, over WiFi. This app is sending its data (x,y coordinates) in a c-struct to the server. For further development, we would like the iPhone application to communicate directly with a java server, however the major issue is that java does not have the...

C struct memory layout?

I have C# background. Very newbie to low level language like C. In C#, struct's memory laid out by compiler by default. Compiler can re-order data fields or pads additional bits between fields implicitly. So I had to specify some special attribute to override this behavior for exact layout. As I know, C does not re-order or align memor...

How to initialize const float32x4x4_t (ARM NEON intrinsic, GCC) ?

I can initialize float32x4_t like this: const float32x4x4_t zero = { 0.0f, 0.0f, 0.0f, 0.0f }; But this code makes an error Incompatible types in initializer: const float32x4x4_t one = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, }; float32x4x4_t is 4x4 matrix bui...

Practical differences between classes and structs in .net (not conceptual)?

Whenever I tried to search about differences between classes and structs in C# or .net, I ended up with the conceptual overview of the two things like value type or the reference type, where the variables are allocated etc. But I need some practical differences. I have found some like different behavior of assignment operator, having con...

C/C++ Struct vs Class

After finishing my C++ class it seemed to me the structs/classes are virtually identical except with a few minor differences. I've never programmed in C before; but I do know that it has structs. In C is it possible to inherit other structs and set a modifier of public/private? If you can do this in regular C why in the world do we nee...

How do I pass (by value) a struct in Objective-C?

This one has been driving me mad! I have a struct: typedef struct{ int a; }myStruct; Then I have: myStruct tempStruct; I am trying to pass the struct to a class method whose implementation is: - (void) myFunc:(struct myStruct)oneOfMyStructs{}; I call the method like so: [myClass myFunc:(struct myStruct)tempStruct]; The com...

C# struct with object as data member

As we know, in C# structs are passed by value, not by reference. So if I have a struct with the following data members: private struct MessageBox { // data members private DateTime dm_DateTimeStamp; // a struct type private TimeSpan dm_TimeSpanInterval; // also a struct private ulong dm_MessageID; // System.Int64 type, ...

How to cast C struct just another struct type if their memory size are equal?

I have 2 matrix structs means equal data but have different form like these: // Matrix type 1. typedef float Scalar; typedef struct { Scalar e[4]; } Vector; typedef struct { Vector e[4]; } Matrix; // Matrix type 2 (you may know this if you're iPhone developer) // Defines CGFloat as float for simple description. typedef float CGFloat; s...