Skip to content

Instantly share code, notes, and snippets.

@ctgnauh
Created April 6, 2023 11:37
Show Gist options
  • Save ctgnauh/b1bffe4d721d59436c89c5b06e4cb8eb to your computer and use it in GitHub Desktop.
Save ctgnauh/b1bffe4d721d59436c89c5b06e4cb8eb to your computer and use it in GitHub Desktop.
Short-circuiting operator in Strict Language
#include <stdio.h>
int firstFunction() {
printf("First Function\n");
return 0;
}
int secondFunctionWithArgumentOne(int one) {
printf("Second Function\n");
return one;
}
int theOne() {
printf("One\n");
return 1;
}
int main()
{
printf("This is the strict evaluation: \n");
int foo = firstFunction() + secondFunctionWithArgumentOne(theOne());
printf("\nThis is the short circuit evaluation: \n");
return firstFunction() && secondFunctionWithArgumentOne(theOne());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment