B
bob
I have a switch in a main function:
int main() {
switch ( 5 ) {
case 1 :
// Process for test = 1
//...
break;
case 5 :
// Process for test = 5
//...
break;
default :
// Process for all other cases.
//...
}
return 0;
}
But when I compile I get:
error: expected primary-expression before '}' token
error: expected `;' before '}' token
Is it illegal to have a switch in a main function?
int main() {
switch ( 5 ) {
case 1 :
// Process for test = 1
//...
break;
case 5 :
// Process for test = 5
//...
break;
default :
// Process for all other cases.
//...
}
return 0;
}
But when I compile I get:
error: expected primary-expression before '}' token
error: expected `;' before '}' token
Is it illegal to have a switch in a main function?