If there’s a structure with a pointer to a struct declared within it, how do you determine the size of the sub-struct?
typedef struct myStruct {
int member;
struct subStruct {
int a;
int b;
} *subStruct_t;
} myStruct_t;
How do you allocate space for the subStruct_t pointer? I was thinking something along the lines of
myStruct_t M;
M.subStruct_t = calloc(1,sizeof(myStruct_t.subStruct_t);
but it obviously doesn’t work. Any ideas?
Note: allocate for the size of the structure, not for the pointer