C Compile Error: array type has incomplete element type C Compile Error: array type has incomplete element type arrays arrays

C Compile Error: array type has incomplete element type


struct NUMBER array[99999];  

should be

NUMBER array[99999];  

because you already typedefed your struct.


EDIT: As OP is claiming that what I suggested him is not working, I compiled this test code and it is working fine:

#include <stdio.h>typedef  struct{    int   num ;} NUMBER ;int main(void){    NUMBER array[99999];    array[0].num = 10;    printf("%d", array[0].num);    return 0;}  

See the running code.


You have

typedef  struct    {               int   num ;    } NUMBER ;

which is a shorthand for

struct anonymous_struct1    {               int   num ;    };typedef struct anonymous_struct1 NUMBER ;

You have now two equivalent types:

struct anonymous_struct1NUMBER

You can use them both, but anonymous_struct1 is in the struct namespace and must always be preceded with struct in order to be used. (That is one major difference between C and C++.)

So either you just do

NUMBER array[99999];

or you define

typedef  struct number    {               int   num ;    } NUMBER ;

or simply

struct number    {               int   num ;    };

and then do

struct number array[99999];