I read that initialization within cases of switch is supposed to give compiler error. But when I tried two different version. One is not giving out the error (Ex1), I can't understand why.
Ex 1:
switch (i)
{
case 1:
int k;
break;
case 2:
int j=3;
break;
}
Ex2:
switch (i)
{
case 1:
int k=3;
break;
case 2:
int j;
break;
}