How do I get this to work? I am not sure how many invoices a customer will be assigned to and want to leave it dynamic. Please help.
#include <stdio.h>
#include <stdlib.h>
typedef struct _cust{
int id;
int invoices[][2];
} cust;
cust account[] = {
{1,{10,100}},
{2,{{10,100},{20,200}}},
{3,{{10,100},{20,200},{30,300}}}
};
int main(void) {
printf("%d\n", account[0].invoices[0][0]);
printf("%d\n", account[1].invoices[1][0]);
printf("%d\n", account[2].invoices[2][0]);
return 0;
}
When I run this code I get following error ...
error: initialization of flexible array member in a nested context
If I give fill in a number something like this int invoices[3][2], the code runs fine.