Created
April 7, 2011 17:49
-
-
Save KushalP/908305 to your computer and use it in GitHub Desktop.
This always prints 'none'
This file contains hidden or 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 <stdio.h> | |
const char *example(int num) { | |
const char *str; | |
switch (num) { | |
case 1: | |
str = "one"; | |
case 2: | |
str = "two"; | |
case 3: | |
str = "three"; | |
default: | |
str = "none"; | |
} | |
return str; | |
} | |
int main(int argc, char **argv) { | |
printf("%s\n", example(2)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you need break;