Search This Blog

Wednesday, November 17, 2010

How can I deal with an array of structs?

Programmer Question

i have this struct:



#define sbuffer 128
#define xbuffer 1024

typedef struct{
char name[sbuffer];
char att[sbuffer];
char type[sbuffer];
int noOfVal;
int ints[xbuffer];
double doubles[xbuffer];
char *strings[xbuffer];
} variable;


i need to make an array from this struct, i did this



variable *vars[512]; //is it right


if i want to put a string i had in s into the name,, i did this:



char *s = "What Ever";
strcpy(vars[0]->name,s);


but this is not work,, any help ???



Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails