Skip to content

Instantly share code, notes, and snippets.

@yoichi yoichi/if_scope.cpp
Created Dec 17, 2014

What would you like to do?
#include <stdio.h>
int main()
if (int x = 0) {
printf("true: %d\n", x);
//printf("true: %d, ?: %d\n", x, y); // ‘y’ was not declared in this scope
} else if (int y = 0) {
printf("false: %d, true: %d\n", x, y);
} else {
printf("false: %d, false: %d\n", x, y);
// output: false: 0, false: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.