initializing char array inside a struct
hi there!
here's my question. i've been struggling about 2 hours with this but haven't figured it out yet.
suppose we have this string array
Code:
char index [INDEXSIZE][STRINGSIZE]={"debug","itterations","population",
"no fix vehicles","pm","pc"};
indexsize is 6, stringsize is 50.
modifying my program required that i will have to implement this array inside a struct. so i did this:
Code:
struct{
char index [INDEXSIZE][STRINGSIZE]={"debug","itterations","population",
"no fix vehicles","pm","pc"};
int val[INDEXSIZE];
}st1;
but when i compile it i get the following message
Code:
teststring.c:20: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
i have faced a somewhat similar problem in another code example and i had to initialize each array element one by one. this concept seems pretty silly to me so please tell me: WHAT AM I DOING WRONG :( ?
i tested many different ways (variable length, character pointer, const specifier, different bracket concept etc) but nothing seems to work...
thanks in advance