C 编译错误 : array type has incomplete element type

标签 c arrays struct compiler-errors

#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/

相关文章:

C - 计数器不工作

c - for循环中的if条件

javascript - 如何过滤90分以上的分数?

以星号结尾的 C 结构

struct - const 值在匿名结构字段中的作用是什么?

c - 如何正确终止 pthread?

c - 围绕初始化器元素的好方法不是 C 中的常量错误吗?

python - 合并数组并根据python中的键添加

python - 以特定方式 reshape Python 数组

c++ - 将结构写入文件