Question 12
Back to Exercise
Is a declaration directly after a case label, as in case 1: int x = 5;, valid?
- A Always valid
- B Invalid before C23 (a label had to be followed by a statement); valid in C23 Correct
- C Never valid
- D Valid only in default
Correct Answer: Option B
Until C17, a label had to label a statement, and a declaration is not one. The usual workaround was braces: case 1: { int x = 5; … }. C23 now allows the declaration directly.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!