#include <stdio.h>
typedef struct
{
int num ;
} NUMBER ;
int main(void)
{
struct NUMBER array[99999];
return 0;
}
编译错误:
error: array type has incomplete element type
我认为问题在于我错误地声明了结构数组。我查了一下好像是这样声明的。
最佳答案
struct NUMBER array[99999];
应该是
NUMBER array[99999];
因为您已经typedef
了您的结构。
编辑:由于 OP 声称我建议他的方法不起作用,我编译了这段测试代码并且运行良好:
#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;
}
参见 running code .
关于C 编译错误 : array type has incomplete element type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21080744/