Can anyone explain the output of this C program?
c, switch-statement
Solution
Initialization of variables inside switch statements is bad practice and undefined behavior.
Problem
Possible Duplicate: Why can't variables be declared in a switch statement? How can a variable be used when its definition is bypassed? ``` #include<stdio.h> int main() { int a=1; switch(a) { int b=20; case 1: printf("b is %d\n",b); break; default:printf("%d\n",b); break; } return 0; } ``` ran on gcc 4.6.3, output not 20. What is going on here?