Created
July 26, 2012 16:53
-
-
Save lukecampbell/3183186 to your computer and use it in GitHub Desktop.
Example of Short Circuiting in C
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
(sci)Lukes-ASA-Macbook:coi-services (dm_coverage +%) luke$ gcc -o /tmp/ss /tmp/short_circuit.c | |
(sci)Lukes-ASA-Macbook:coi-services (dm_coverage +%) luke$ /tmp/ss | |
End of program. |
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 <stdio.h> | |
int do_something(void) | |
{ | |
printf("You shouldn't see this.\n"); | |
return 1; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
if(0 && do_something()) | |
{ | |
printf("You REALLY shouldn't see this.\n"); | |
} | |
printf("End of program.\n"); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment