I'm using this structure below, but it's limited if I want to get all String from a huge file...
typedef struct arr {
char name[200]; // Could be a number higher than 200 here...
} array;
Now, if I use...
typedef struct arr {
char *name;
} array;
Then, is it possible to allocate memory for a char pointer (*name) that is inside a struct (array)?
I don't know what I did wrong, I allocate memory for array, but somehow, I got a Segmentation fault error. The struct with name[200]
didn't give me any error. The struct with *name
does.
array *str = malloc(sizeof(*str));
Did I miss to allocate something else?