How does one malloc a struct which is inside another struct?
I would also like to malloc an array of items inside a struct and then realloc this array when needed, how i
typedef struct _A { int i; } A; typedef struct _B { int j; A a} B;
To get a single B:
B *b = malloc(sizeof(B));
To get an array of B:
B *b = malloc(sizeof(B) * arrayLength);