Hi all, following is the cope snippet that i am trying to run. Code: #include<stdio.h> int main() { int a=1; switch(a) { int b=20; case 1: printf("b is %d\n",b); break; default:printf("b is %d\n",b); break; } return 0; } i jus wanted to know whether the statements inside the switch statement but outside all the case blocks will execute or not. Thanks in advance, Gangadhar
You have posted it as an Article under the Article / Source code section. I have moved it to the Queries and Discussion forum. It should not and in MS compiler its an error.
thanks shabbir, for moving my query to the right place.. but it wont give error on unix platform. plz gimme some more info. Thanks, Gangadhar
ya i got.. "warning : Statement can never be reached." but still its printing no. If the statement is not reachable, it should give an error saying that the variable 'b' is not defined. And more over, how can it take it as zero?
its some thing like writing some statement after the return statement. Its will also give something like code unreachable. 0 is the default value and so its not initialized but as the var is defined its showing as 0