linux 错误:只允许在 C99 模式下使用‘for’循环初始化声明
rwxr-xr-x 1 root root 9592 8月16 21:27 main。a.c:3:6: 附注:使用 -std=c99 或 -std=gnu99 来编译您的代码。-rw-r--r-- 1 root root112 8月16 21:25 a.c。a.c:3:6: 错误:只允许在 C99 模式下使用‘for’循环初始化声明。错误:只允许在 C99 模式下使用‘for’循环初始化声明。
记录
程序信息
#include <stdio.h>
int main() {
for (int i= 1; i<= 5;i++){
printf("%d ",i);
}
return 0;
}
错误:只允许在 C99 模式下使用‘for’循环初始化声明
[root@opengauss test01]# gcc a.c
a.c: 在函数‘main’中:
a.c:3:6: 错误:只允许在 C99 模式下使用‘for’循环初始化声明
for (int i= 1; i<= 5;i++){
^
a.c:3:6: 附注:使用 -std=c99 或 -std=gnu99 来编译您的代码
[root@opengauss test01]#
[root@opengauss test01]#
[root@opengauss test01]# gcc -g -std=c99 a.c -o main
[root@opengauss test01]# ll
总用量 16
-rw-r--r-- 1 root root 112 8月 16 21:25 a.c
-rwxr-xr-x 1 root root 9592 8月 16 21:27 main
[root@opengauss test01]# ./main
1 2 3 4 5 [root@opengauss test01]#
[root@opengauss test01]#
截屏

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)