struct

How to set retain for properties nested to struct ?

Hi, There is really something in objc I cannot understand. I know how to make retainable properties but cannot understand how to make retainable "sub" struc fields which are not "public" properties but only "private" properties (the private properties are only managed by my methods). Here is my code: struct _device_descriptor { ...

Visualising C structs?

Hi all, I am using Ubuntu 10.04, and studying programming of kernel objects. I have come across some rather complicated structs which I have difficulties reading, so I thought I'd try to find some tool that can help me visualise them. Only thing I could find so far is VCG, which has a C Struct Visualization Example, which looks like...

how to select instance from a list in c#

i have a struct who have a list of item and some other variable about struct i want to check that a enum in list have a specific value or not. like struct.list.havevalue == 5; how i can count all who have the specific value in enum in the itemlist of the structure ...

expected constructor, destructor, or type conversion before ‘.’ token

BALL ball1;//,ball2,ball3; ball1.bx = 0; ball1.by = 0; ball1.bvx = 1.0; ball1.bvy = 1.0; ball1.radius = 5.0; BALL is a struct in a separate.h file where I have used the following code : typedef struct ball { GLfloat bx; GLfloat by; GLfloat bvx; GLfloat bvy; GLfloat radius; }BALL; typedef struct paddle { GLfloat length; GLfloa...

Struct v/s Class in C# - Please explain the behavior.

Hello Folks, Could someone please explain the behavior of this class testCompile { /* * Sample Code For Purpose of Illustration */ struct person { public int age; public string name; } static void Main(string[] args) { List<person> L...

const C Struct Array within Struct Array

I am attempting to create a const structure in C but can't seem to figure it out. typedef struct sA{ char* fname; char* lname; } A; To use as an Array: A list[] = {{"david","smith"},{"john","smith"}}; However, if I have use a second struct: typedef struct sB{ A inList[]; } B; I want to define a const structure as: B newList...

Is there any way to prepare a struct for future additions?

I have the following struct which will be used to hold plugin information. I am very sure this will change (added to most probably) over time. Is there anything better to do here than what I have done assuming that this file is going to be fixed? struct PluginInfo { public: std::string s_Author; std::string s_Process...

Wavefront OBJ: Converting from Objective-C string to C struct apparently incorrect

I'm writing a Wavefront object loader for work because I don't feel comfortable using code I don't understand in professional projects. After the obvious first step, sorting out which parts are which, I'm attempting to load and log vertices. First and foremost, I wrote a C struct to hold the values. struct Vertice { float x; flo...

C++ struct array copy

Guys, I want to copy elements of a struct array to another by using memcpy. I believe this is miserably causing my program to fail for some reason. Also how can I free the memory in the end ? struct FaultCodes { string troubleFound; string causeCode; string actionCode; string paymentCode; string suppCode; u_int16_t multipli...

Passing a Structure to C++ API using Marshal.StructureToPtr in C#

Hi, I am using API written in C++ in my code (writting in C#). API requires a parameter as Pointer to Structure. The Structure cosists of "Int"s and Char Arrays: for example unsafe public struct ToBePassed { Int32 Num1; Int32 Num2; Char[] Data; // or fixed Char Data[255]; } I can not directly pass...

How to initialize a struct in C#

I have some code to initialize a struct in C#: namespace Practice { public struct Point { public int _x; public int _y; public int X { get { return _x; } set { _x = value; } } public int Y { get { return _y; } set { _y = val...

variable declaration problem inside struct

I declared a Normal Structure In C: typedef struct arr_struct{ int* original; int size; int first[size/2]; int second[size-(size/2)]; }; when compile it gives me: test.c:11: error: ‘size’ undeclared here (not in a function) any explanation? ...

C - Losing pointee struct values

**Updated. Sorry to those whose answers no longer make sense. So I figured out that no matter what I put on the line after Data_pair_node, after it executes, thats when the thing is reset! WTH? : int insert(Table *t, const char *key, const char *val){ int dest_bucket_index; Table *table = t; Hash_bucket *dest_bucket = NULL; Data_pa...

Declaring a struct method in C++

I'm trying to create a recurring struct method in my code to walk through a binary search tree. But I'm getting errors on compile and unsure what is the cause. I've got Node* findNode(const Node *, const Object &); in the private section of the .h file and Node* BSTree::findNode(const Node* current, const Object &target){ if(*current...

4-bit Enum in C#

I know that its possible to make enums that use signed or unsigned 64, 32, 16, and 8 bit values as their underlying valud type using (:ulong, :uint, :ushort, :byte). But is it possible to create a 4 bit enum? (I'm writing some code that will interop with C++ and the struct that I have in C# for a return type has one field that would be...

Struct Scope Access

Hi this a continuation of a previous question I asked however I wasn't registered then and thus cannot edit the question. Anyways I have a struct typedef struct { char input[100][100]; int count; char name; int startTime; }INPUT; extern INPUT *global; this is within the header file. A stackoverflow member suggested that in my sou...

Swap nodes in a double linked list - slow sorting algorithm drops nodes

For practice, I've been working on a compressor which does the find-repeated-parts, make-dictionary, compress-with-huffman codes thing. It's not really working. One of the problems is, for some reason my sorting algorithm drops keywords from the dictionary. I think the problem is in the swap routine, but I'm not sure. ( this routine ...

Storing a struct in an NSArray

Hello! Back with my daily silly question. Today I'm trying to put a struct in an NSArray. Alright, that's easy, wrap it in a NSData. If you know me, you know you're about to see code. In this example, I'm loading a vertex line from a Wavefront OBJ into a struct and sticking it in an array. NSArray *verticeLineParts = [currentLin...

Filling 4 variable in a struct type and using malloc

I need to write a simple program that ask the user to insert 4 double type variable in a struct variable data. struct Data { double a; double b; double c; double average; }; struct Data *ptr_name; int i; First, ask user the size: printf("Please enter the size:"); scanf("%d", &size); Then, use ...

Opaque C structs: how should they be declared?

I've seen both of the following two styles of declaring opaque types in C APIs. Is there any clear advantage to using one style over the other? Option 1 // foo.h typedef struct foo * fooRef; void doStuff(fooRef f); // foo.c struct foo { int x; int y; }; Option 2 // foo.h typedef struct _foo foo; void doStuff(foo *f); // fo...