just wondering, how do you use global arrays of a structure’s?
For example:
int y = 0;
object objectArray [100];
typedef struct object{
time_t objectTime;
int objectNumber;
} object;
int main(void)
{
while(1)
{
time_t time_now;
time_now = time(NULL);
object x = {time_now, objectNo}
objectArray[y] = x;
y++;
}
}
This always throws an “error: array type has incomplete element type”, can anybody advise me of the problem and an appropriate solution?
Thanks
Move the definition of the struct to before your declaration of the array:
You’re getting that error because the compiler doesn’t know the size of
objectwhen it gets to the array declaration.