在使用switch时 在case 后面申请变量会出现 error: a declaration cannot have a label错误
原因:Case statements are only 'labels'. This means the compiler will interpret this as a jump directly to the label.The problem here is one of scope. Your curly brackets define the scope as everything inside the 'switch' statement. This means that you are left with a scope where a jump will be performed further into the code skipping the initialization. The correct way to handle this is to define a scope specific to that case statement and define your variable within it.
解决方法:在case 后面加一个{ }做相应的操作。