I am trying to allocate memory for an array of C strings. I can guarantee that the strings fit within MAX_STRING_LENGTH
characters, but I don't know at compile time how many strings will be in the array (this is computed dynamically). When I use the code...
char *strings[MAX_STRING_LENGTH] = malloc( sizeof(char *) * numstrings );
...the compiler complains that this is an invalid initializer. When I use the code...
char strings[MAX_STRING_LENGTH][] = malloc( sizeof(char *) * numstrings );
...the compiler complains about an incomplete element type. What am I doing wrong here, and how can I allocate memory for this array?