That white space is unecessary and so is the semi-colon on line 21.
As for the answer the compiler MS uses requires a command to be inside the last case.
the compiler MS uses requires a command to be inside the last case.
the version of the loop I posted compiles, however when you delete the break statements it doesn't
error C2143: syntax error : missing ';' before '}'
wait your missing the closed braces after return 0;
stop being silly, I know your trying to help but it was a copy paste error.
no default doesn't need a break (neither do the others), but the answer to the problem is I have said already the compiler will not compile if there is no command in the last statement of the switch whatever that may be.
ive never ran a swich without some type of code in them. default doesn't need a break but the others do or it iterates through all the cases. I'm not only trying to help I'm trying to learn and thats not silly goose
that doesn't mean they have to be in there, what happens if I want all commands in the switch to execute if the case is 1, and only commands 2-n if the case is 2, and 3-n if the case is 3 and so on...?
You don't seem to get my point at all.
I'm answering the OP's question:
in the case of:
1 2 3 4 5 6 7 8 9 10 11
switch(opt)
{
case 1: break;
//...
case 2: break;
//...
case 3: break;
//...
default:
}
the code will not compile.
in the case of:
1 2 3 4 5 6 7 8 9
switch(opt)
{
case 1: break;
//...
case 2: break;
//...
case 3:
}
The code does not compile. The op was asking why, the answer is simply: the last case whether that be default, or case 27387237, needs to have a command, function, or break something anything that does something... It CANNOT BE BLANK.