`case` — C Keyword
`case` — C Keyword
The case keyword in C: defines a labeled branch within a switch statement.
`case` — C Keyword
The case keyword in C: defines a labeled branch within a switch statement.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
case (C)Defines a labeled branch within a switch statement. Execution jumps to the first matching case.
switch (expr) {
case constant: statements
}
#include <stdio.h>
int main(void) {
char c = 'a';
switch (c) {
case 'a': case 'e': case 'i':
case 'o': case 'u':
printf("vowel\n"); /* executed */
break;
default:
printf("consonant\n");
}
return 0;
}
case must be an integer constant expression unique within the switch.case labels can share a body (fall-through grouping).switchint main() {
// Pick one facility from this reference page.
// Write the smallest program that exercises its main precondition,
// complexity rule, or lifetime constraint before scaling up.
return 0;
}