1 int func()
 2 {
 3     printf("In func, before continue.\n");
 4 //    continue;
 5     break;
 6     printf("In func, after continue.\n");
 7 }
 8 int main()
 9 {
10     func();
11     return 0;
12 }

第4、第5行分别注释, 来编译看看:

[zyc@localhost personalCode]$ vim tmp.c
[zyc@localhost personalCode]$ gcc tmp.c
tmp.c: In function ‘func’:
tmp.c:5:2: error: continue statement not within a loop
  continue;
  ^
[zyc@localhost personalCode]$ vim tmp.c
[zyc@localhost personalCode]$ gcc tmp.c
tmp.c: In function ‘func’:
tmp.c:6:2: error: break statement not within loop or switch
  break;
  ^

我只翻译上面报错的两句:

error: continue语句不在一个循环里

error: break语句不在一个循环或者选择(语句)里

 

可见,不能用break或者continue从函数里面跳转出来

 

相关文章:

  • 2021-12-02
  • 2021-08-31
  • 2021-12-10
  • 2021-10-20
  • 2022-12-23
  • 2021-11-23
  • 2021-12-02
猜你喜欢
  • 2021-10-31
  • 2021-12-25
  • 2021-08-26
  • 2022-12-23
  • 2022-02-12
相关资源
相似解决方案