break

what may be reason of error it is showing errors 1.break statement is not in a loop 2.case label not in a switch statement!
1
2
3
4
5
6
  case 3: display();
    printf("presh 1 to continue else other key");
    if(getch()!=1)
    break;
    else
    goto choice;
Show surrounding code starting with the swiych statement for which label case 3: belongs.
I'd bet you forgot to enclose your switch case statement in a set of brackets so it's only including the line immediately following the switch statement as part of the test. But like vlad says, we needs mo' code.
i m done! thank you error was brackets around switch!
Last edited on
I think it is not the break that is the reason of the error. it is the continue that is the reason of the compiler message. continur may not be used outside any loop. The swicth statement is not a loop statement.
Take also into account that variable choice was not declared. It is used simply as

choice:

EDIT:
Or is it a label? As you deleted the code I am not sure now what is the choice.:)
it seems there was statement

switch( choice )

I do not remember.
Last edited on
Don't delete your posts, I've posted even worse garbage on this site and you won't see me removing it because of something silly like pride. Also vlad brought up several legitimate concerns that need to be addressed.
Topic archived. No new replies allowed.