how to properly free a char **table in C
- by Samantha
Hello,
I need your advice on this piece of code:
the table fields options[0], options[1] etc... don't seem to be freed correctly.
Thanks for your answers
int main()
{
....
char **options;
options = generate_fields(user_input);
for(i = 0; i < sizeof(options) / sizeof(options[0]); i++) {
free(options[i]);
options[i] = NULL;
}
free(options);
}
char ** generate_fields(char *)
{
char ** options = malloc(256*sizeof(char *));
...
return options;
}