Created
November 27, 2013 22:05
-
-
Save Diti/7684035 to your computer and use it in GitHub Desktop.
Adding a `case` after the default one in a `switch` control structure still works.
Compiled on a POSIX system with `gcc` and flags `-Wall -Wextra -pedantic -std=c89`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
void say(int x) | |
{ | |
switch(x) | |
{ | |
case 0: | |
write(1, "Case 0\n", 7); | |
break; | |
default: | |
write(1, "Case default\n", 13); | |
break; | |
case 1: | |
write(1, "Case 1\n", 7); | |
break; | |
} | |
} | |
int main(void) | |
{ | |
say(0); /* Case 0 */ | |
say(1); /* Case 1 */ | |
say(-1); /* Case default */ | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment