C Switch-case curly braces after every case

前端 未结 5 1880
感动是毒
感动是毒 2020-12-08 02:07

In a C switch-case flow control, it\'s required to put curly braces { } after a case if variables are being defined in that block.

5条回答
  •  星月不相逢
    2020-12-08 02:34

    I consider it bad style to use braces in each case. Cases are labels in C, akin to goto labels. And in the current C language, you're free to declare variables in each case (or anywhere you like) without introducing new blocks, though some people (myself included) also consider that bad style.

提交回复
热议问题