Skip to content

Instantly share code, notes, and snippets.

@me-shaon
Last active November 16, 2017 15:18
Show Gist options
  • Save me-shaon/8e9ab8688ce4cb357bc99c520ce6fe62 to your computer and use it in GitHub Desktop.
Save me-shaon/8e9ab8688ce4cb357bc99c520ce6fe62 to your computer and use it in GitHub Desktop.
Sample Block Scope example for Medium article
void testFunction() { //Scope 1: Starts here. This scope is created by the Function block
int a = 1;
if(true) { //Scope 2: Starts here. This scope created by the 'if' block
int b = 2;
//a is available here, because it is inside of it's scope
printf("%d %d", a, b);
}//Scope 2: Ends here
//'b' is not available here, because it is out of it's scope
} //Scope 1: Ends here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment