int size;struct demo{ int a;};int main(){ scanf("%d",&size); struct demo d[size]; return 0;}
这段代码工作正常.
代码2: –
int size;struct demo{ int a;};int main(){ scanf("%d",&size); return 0;}struct demo d[size];
此代码显示错误: –
error : variably modifIEd 'd' at file scope
为什么这样的错误会出现在Code 2中,而Code 1运行正常?
解决方法 在代码2中,您的结构数组驻留在数据段中,根据定义总结A data segment is a portion of virtual address space of a program,
which contains the global variables and static variables that are
initialized by the programmer. The size of this segment is determined by the values placed there by the programmer before the program was compiled or assembled,and does not change at run-time.
以上是内存溢出为你收集整理的错误:在文件范围内修改了’d’全部内容,希望文章能够帮你解决错误:在文件范围内修改了’d’所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)