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.
Generally it is bad practice jump over the initialization of a variable, be it with goto
or switch
. This is what happens when you don't have the the blocks per case
.
There is even a case in C99 where jumping over the initialization is illegal, namely variable length arrays. They must be "constructed" similarly as non-PODs in C++, their initialization is necessary for the access of the variable later. So in this case you must use the block statement.