Created
January 20, 2017 19:06
-
-
Save akoskovacs/8c3cc10e9e9daaad0cd880ea4279d67c to your computer and use it in GitHub Desktop.
Implementing if statement in GNU C with goto
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> | |
/* | |
* if (argc == 1) { | |
* printf("argc equals one\n"); | |
* } else { | |
* printf("argc is not one (%d)\n", argc); | |
* } | |
* return argc; | |
*/ | |
int main(int argc, const char *argv[]) | |
{ | |
goto *((argc == 1) ? &&argc_one : &&argc_other); | |
argc_one: | |
printf("argc equals one\n"); | |
goto end; | |
argc_other: | |
printf("argc is not one (%d)\n", argc); | |
goto end; | |
end: | |
return argc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment