error: a label can only be part of a statement and a declaration is not a statement

Posted 菜地

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了error: a label can only be part of a statement and a declaration is not a statement相关的知识,希望对你有一定的参考价值。

GCC:

error: a label can only be part of a statement and a declaration is not a statement

 

switch(a){        swtch(a){

case 1:         case 1:

....................       {

....................        ...............

....................        ...............

break;          ................

case 2:         }

break;          break;

}            case 2:

             break;

            }

Error         OK

 

 

case1:
//此块代码不能再声明变量,如果你声明变量就会报错,除非用括号括起来,这是编译器的问题,也可以说是C语言的规定。写代码的时候注意就成了。就像C语言再声明的时候不能赋值一样,记住就好了。
break;
希望对你有所帮助。

以上是关于error: 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”解决方法

C语言常见问题(11):a label can only be part of a statement and a declaration is not a statement

C语言常见问题(11):a label can only be part of a statement and a declaration is not a statement

C语言常见问题(11):a label can only be part of a statement and a declaration is not a statement

PWC6199:Generated servlet error:Only a type can be imported. org.apache.jasper.tagplugins.jstl.core.

Error: Finish can only be called once