switch 错误:a label can only be part of a statement and a declaration is not a statement
来源:互联网 发布:各地大数据项目 编辑:程序博客网 时间:2024/06/05 08:53
现象:
switch(a){case 1:............................................................break;case 2:break;}
在GCC下编译会出现如下错误:error: a label can only be part of a statement and a declaration is not a statement但加上如下括号后,就没有错误了,这是为什么?编译器的问题?switch(a){case 1:{............................................................}break;case 2:break;}
原因:
case1://此块代码不能再声明变量,如果你声明变量就会报错,除非用括号括起来,这是编译器的问题,也可以说是C语言的规定。写代码的时候注意就成了。就像C语言再声明的时候不能赋值一样,记住就好了。break;
0 0
- switch引发的错误 a label can only be part of a statement and a declaration is not a statement
- switch引发的错误:a label can only be part of a statement and a declaration is not a statement
- switch 错误:a label can only be part of a statement and a declaration is not a statement
- switch引发的错误 a label can only be part of a statement and a declaration is not a statement
- switch引发的错误 a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- a label can only be part of a statement and a declaration is not a statement
- 错误“a label can only be part of a statement and a declaration is not a statement”解决方法
- 错误“a label can only be part of a statement and a declaration is not a statement”解决方法
- 转:switch引发的错误:a label can only be part of a statement and a declaration is not a statement
- error: a label can only be part of a statement and a declaration is not a statement
- ERROR:a label can only be part of a statement and a declaration is not a statement
- 【C/C++】error: a label can only be part of a statement and a declaration is not a statement
- C语言:error: a label can only be part of a statement and a declaration is not a statement|
- 第十三周项目五~~拓扑排序算法验证
- SPI FLASH存储设计一
- PHP路由技术的原理与实践
- 第十周项目4 输出所有叶子节点
- 第13周项目
- switch 错误:a label can only be part of a statement and a declaration is not a statement
- 第四周 项目1--建立单链表
- 第十三周实践项目—验证算法(1)Prim算法的验证
- 拓扑排序
- AndroidStudio签名
- 第十一周项目5 用二叉树求解代数表达式
- 第13周上机实践项目 - 验证算法(3)Dijkstra算法的验证
- Android: The connection to adb is down, and a severe error has occured.
- su -c命令与环境变量的困惑