I have to know if there is a way to declare inside a struct a variable length string array, something like that
struct node {
int k;
char * arr[length_variable];
}
Now I'm doing something like that
struct node {
int k;
char ** arr;
}
int main()
{
...
struct node * n = (struct node*)malloc(sizeof(struct node));
n->arr = malloc(sizeof(char*)*length_of_first_array); //the length of the array is variable
n->arr[0] = malloc(sizeof(char)*length_first_string+1); //+1 is for \0 character
strcpy(n->arr[0],"word");
...
}
Unfortunately analising the output code using valgrind tool 'memory check' it seems that something is wrong with my mallocs.
VLA != FAM