Switch Statements

前端 未结 4 669
遇见更好的自我
遇见更好的自我 2021-01-18 22:14

For switch statements, is it possible to change the value of the switch inside the switch statement so that it can jump around to different cases? Ex:

int w          


        
4条回答
  •  滥情空心
    2021-01-18 22:40

    Yes you can change the value inside switch but it will not execute case for new value until you break in the case where you changed the value.

    In your case it will not go in any case as there is no case for 0. But if you change to w = 1 then it will go for case 1 and then for case 2 as you do not have break; but it will not go for case 3.

提交回复
热议问题