M
MackS
I've come across the following difficulty, related to questions 6.12,
6.13 and 6.18 in the FAQ, which I am unable to overcome:
void fun(char **array_of_strings, int num_elements);
int main(void)
{
char static_array_of_strings[NUM_STRINGS][MAX_STRING_LEN+1];
fun ((char**)&static_array_of_strings, NUM_STRINGS);
return 0;
}
This code compiles but is wrong (I get a segmentation fault). How can I
correctly call fun on static_array_of_strings?
I can't modify the prototype of fun() because it also receives "true"
char** (in the sense of dynamically allocated arrays of strings, ie,
both the number of elements in the array as well as the length of each
string are unknown size at compile time).
How can I pass static_array_of_strings to it? The way I read FAQ 6.18
suggests this is impossible and the prototype of fun() would have to
modified to include MAX_STRING_LEN+1.
Thank you for any help,
Mack
6.13 and 6.18 in the FAQ, which I am unable to overcome:
void fun(char **array_of_strings, int num_elements);
int main(void)
{
char static_array_of_strings[NUM_STRINGS][MAX_STRING_LEN+1];
fun ((char**)&static_array_of_strings, NUM_STRINGS);
return 0;
}
This code compiles but is wrong (I get a segmentation fault). How can I
correctly call fun on static_array_of_strings?
I can't modify the prototype of fun() because it also receives "true"
char** (in the sense of dynamically allocated arrays of strings, ie,
both the number of elements in the array as well as the length of each
string are unknown size at compile time).
How can I pass static_array_of_strings to it? The way I read FAQ 6.18
suggests this is impossible and the prototype of fun() would have to
modified to include MAX_STRING_LEN+1.
Thank you for any help,
Mack