This may be a dumb question, and I’m shocked I had trouble Googling it, but here goes:
What happens in this situation:
int foo(void){
char x = 1;
if (x == 1}
goto apple;
}
else{
goto banana;
}
apple:
printf("apple");
banana:
printf("banana");
return 0;
}
If x==1 will the output be
apple
banana
Or will it just be apple and stop at the end of the label? Like will the code continue to be executed line by line and enter the other label?
Yes, it will. Labels (either
gotoorswitchlabels) fall through.