I need to create a data structure of data structures, but I can know "how many structs I need" only at runtime.
typedef struct tagPredefinedStruct{
int iSize;
int iCount;
} PREDEFINEDSTRUCT;
int x;
x = GetNumberofStructs(); //x is known only at runtime.
typedef struct APIStruct {
int iNumber;
PREDEFINEDSTRUCT PreDefStruct[x];
int iDate;
} APISTRUCT;
Currently, the compiler gives an error C2057: expected constant expression
for PreDefStruct[x]
.
I have to pass the address of this APISTRUCT
structure to an API so I need all the memory allocated together in a chunk and can't use linked lists.
Thanks a lot for reading my post. I graciously await your response.