C
ccdrbrg
I am trying to initialize an arrary of
pointers to structs with constants.
Sample code:
struct mystruct {
char *text;
int number;
};
struct mystruct *array[] = {
{"string1", 1},
{"string2", 2},
{"string3", 3},
};
GCC complains: "braces around scaler initializer"
I would think {"string1", 1} would be
replaced with an address upon compilation.
For example,
char *strings[] = {"string1", "string2", NULL};
works.
Any help would be appreciated.
Chad
pointers to structs with constants.
Sample code:
struct mystruct {
char *text;
int number;
};
struct mystruct *array[] = {
{"string1", 1},
{"string2", 2},
{"string3", 3},
};
GCC complains: "braces around scaler initializer"
I would think {"string1", 1} would be
replaced with an address upon compilation.
For example,
char *strings[] = {"string1", "string2", NULL};
works.
Any help would be appreciated.
Chad