mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
[C/en] Added tidbit about fall-though in switch statements.
Another pitfall, as not all languages have fall-through in switches.
This commit is contained in:
parent
927ac9c3e8
commit
3b1940b9cc
@ -318,6 +318,12 @@ int main (int argc, char** argv)
|
||||
case 1:
|
||||
printf("Huh, 'a' equals 1!\n");
|
||||
break;
|
||||
// Be careful - without a "break", execution continues until the
|
||||
// next "break" is reached.
|
||||
case 3:
|
||||
case 4:
|
||||
printf("Look at that.. 'a' is either 3, or 4\n");
|
||||
break;
|
||||
default:
|
||||
// if `some_integral_expression` didn't match any of the labels
|
||||
fputs("error!\n", stderr);
|
||||
|
Loading…
Reference in New Issue
Block a user