First of all, you are completely misusing switch-case.
Example of how it should be used:
Is equivilent to:Code:if(someVariable==1) { //do Something #1 } else if(someVariable==2) { //do Something #2 } else if(someVariable==3) { //do Something #3 } else { //do something different }
Second, while goto's are supported in C/C++ and are closer to how machine code works, they are generally considered poor coding form, as they get really confusing if they span longer than one page on the screen. This is nicknamed "spagetti code".Code:switch(someVariable) { case 1: //do the code below when someVariable==1 //do Something #1 break; case 2: //do the code below when someVariable==2 //do Something #2 break; case 3: //do the code below when someVariable==3 //do Something #3 break; default: //do the code below when someVariable any other value //do something different }




Reply With Quote