mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-24 10:01:38 +00:00
Merge pull request #1872 from luehm/c_cases
[C/en] Added tidbit about fall-though in switch statements.
This commit is contained in:
commit
6eeb1f962e
@ -313,6 +313,12 @@ int main (int argc, char** argv)
|
|||||||
case 1:
|
case 1:
|
||||||
printf("Huh, 'a' equals 1!\n");
|
printf("Huh, 'a' equals 1!\n");
|
||||||
break;
|
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:
|
default:
|
||||||
// if `some_integral_expression` didn't match any of the labels
|
// if `some_integral_expression` didn't match any of the labels
|
||||||
fputs("error!\n", stderr);
|
fputs("error!\n", stderr);
|
||||||
|
Loading…
Reference in New Issue
Block a user