Two dimensional array as buffer for string list
I have a function which sets a pointer equal to a requested list of strings.
Some of the string lists are fixed:
Code:
char *configlist[NCONFIGS] = {"Ser", "Par", "Coil a", "Coil b"};
char *taperlist[NTAPERS] = {"Lin", "Log1, Log2"};
Other string lists are created within the function, and they need to be of the same type as the fixed lists (char **) so that either can be assingned to the pointer.
And so I have:
Code:
char *itemlist[MAXITEMS];
char listbuffer[MAXITEMS][MAXITEMLENGTH]:
and the string pointers initially assigned:
Code:
for(int i = 0; i < MAXITEMS; i++)
itemlist[i] = listbuffer[i];
Is it safe to use a two dimensional array as buffer like that?
Is listbuffer[n] guaranteed to point to listbuffer[n][0] ?
-