test.c:12:17: error: break statement not within loop or switch

 

001、

复制代码
[root@localhost test]# ls
test.c
[root@localhost test]# cat test.c
#include <stdio.h>

int main(void)

{
        int i;
        printf("i = "); scanf("%d", &i);

        if(i > 0)
        {
                puts("greater than 0");
                break;
        }
        else
        {
                puts("less than 0");
        }

        return 0;
}
[root@localhost test]# gcc test.c -o kk
test.c: In function ‘main’:
test.c:12:17: error: break statement not within loop or switch    ## break声明仅仅用于loop和switch语句中
   12 |                 break;
      |                 ^~~~~
复制代码

 。

 

posted @   小鲨鱼2018  阅读(30)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2023-09-19 linux 中 trimmomatic软件的安装及使用
2023-09-19 linux 中awk命令删除文件的最后一列或最后几列、提取文件的第一列、前几列
2023-09-19 linux中正则表达式仅保留绝对路径的目录
2022-09-19 ubuntu 22.04中利用conda 安装 delly软件
2022-09-19 centos7 中 使用conda安装 Pindel 软件
2022-09-19 centos 7 中使用conda 安装 BreakDancer软件
2022-09-19 centos7 中如何安装anaconda
点击右上角即可分享
微信分享提示