how to know dynamic size of struct
Suppose i have a program that is consisted of a struct. this struct will be used as an array.
How do i define an flexible array for this struc ? i don't know how many arrays which i need yet.
and how can i calculate the sum of all person salary ?
I wrote the simple code, but i think not solve my problem
int sumStructs(person*, int);
person a, *pa; /* I still put non flexible array*/
pa = a;
int i = 0;
for(i=0; i< 10; i++)
a[i].i = i+1;
int d = sizeof(a)/sizeof(person);
int c = sumStructs(pa, d);
printf("sum i adalah %d \n",c);
int sumStructs(person*pa, int d)
int sum = 0, j= 0;
sum += (*pa).i;