Last active
December 13, 2015 18:29
-
-
Save elarkin/4955920 to your computer and use it in GitHub Desktop.
If statements introduce scope.
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> | |
int main() | |
{ | |
int foo = 4; | |
if(1) { | |
int foo = 5; | |
printf("%i", foo); | |
} | |
printf("%i", foo); | |
} | |
//The output will be 54 instead of 55 since scope is introduced. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment