Skip to content

Instantly share code, notes, and snippets.

@lukecampbell
Created July 26, 2012 16:53
Show Gist options
  • Save lukecampbell/3183186 to your computer and use it in GitHub Desktop.
Save lukecampbell/3183186 to your computer and use it in GitHub Desktop.
Example of Short Circuiting in C
(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.
#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