This is the same as creating any other array in C, except that the type is replaced with Baa
int size = 5;
Baa baaArray[size];
int i;
for(i = 0; i < size; i++)
{
baaArray[i].x = i;
baaArray[i].y = i*10;
}
You can also use pointers and malloc for this:
int size = 5;
Baa *baaPtr = malloc(sizeof(Baa) * size);
Hope this helps.
source
share