C error Variably modified at the file scope [duplicate]

六月ゝ 毕业季﹏ 提交于 2021-02-11 15:12:05

问题


yeah so im new to c and i came across an error when dealing with the following code.:

typedef struct{
    int head;
    int length;
    Customer customer[MAX_LENGTH];

} CustomerCi;

and the error that came out was:

"error: variably modified 'customer' at the file scope"

i have no idea how to fix this and any help would be appreciated (keep in mind that im new to this if it seems like a dumb problem).


回答1:


Replace MAX_LENGTH with a literal value:

#define MAX_LENGTH 32

for example.



来源:https://stackoverflow.com/questions/20292639/c-error-variably-modified-at-the-file-scope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!