Compile Error with: switch, “expected expression before”

后端 未结 3 1684
礼貌的吻别
礼貌的吻别 2020-12-07 18:28

Cut to the chase I have recreated my problem as it is fairly self explanatory.

this complies without error:

switch (n) {
    case 1         


        
3条回答
  •  执笔经年
    2020-12-07 18:42

    You can't declare a variable as the first statement in a case without brackets, and in many other contexts in C-based languages. See Declaring variables inside a switch statement for details.

提交回复
热议问题