`default` — C Keyword
`default` — C Keyword
The default keyword in C: fallback branch in a switch statement.
`default` — C Keyword
The default keyword in C: fallback branch in a switch statement.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
default (C)Marks the fallback branch in a switch statement, executed when no case label matches.
switch (expr) {
case N: ...
default: statements
}
#include <stdio.h>
int main(void) {
int code = 99;
switch (code) {
case 0: printf("OK\n"); break;
case 1: printf("Error\n"); break;
default: printf("Unknown\n"); break; /* executed */
}
return 0;
}
default per switch.default may appear anywhere in the switch, but conventionally goes last.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;
}