Say the structure for the file I want to read looks like this:
typedef struct {
char length;
char* text;
} name;
typedef struct {
long n_names;
name* names;
} file;
In the file there is first the number of names, followed by the list of names with dynamic lengths. So I need to allocate memory for the names array, but before I can do that I first need to know the lengths of all the names.
How can I work this out?