Created
April 6, 2023 11:37
-
-
Save ctgnauh/b1bffe4d721d59436c89c5b06e4cb8eb to your computer and use it in GitHub Desktop.
Short-circuiting operator in Strict Language
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 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