Thread: switch() inside while()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Awesomefaceradcore bivhitscar's Avatar
    Join Date
    Apr 2006
    Location
    Melbourne, Australia
    Posts
    210
    Code:
    while(blah) {
    	switch(blah) {
    	case BLAH:
    		break;
    	}
    }
    The break and continue statements will work only for their directly related process. You can also break out of nested functions too.


    Code:
    while( 1 ) {
    	for ( i = 0; i < 10; i++ )
    	{
    		switch(blah) {
    			case 1:
    			break; //break out of the switch
    			
    			case 2:
    			break;
    			break; //break from the switch and the for
    			
    			case 3:
    			break;
    			break:
    			break; //break from the switch, for and while
    			}
    			
    	}
    }
    Last edited by bivhitscar; 04-22-2006 at 10:29 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. nested switch issue
    By fsu_altek in forum C Programming
    Replies: 3
    Last Post: 02-15-2006, 10:29 PM
  2. A nested if inside the switch
    By Extropian in forum C Programming
    Replies: 20
    Last Post: 08-15-2005, 01:23 AM
  3. Switch
    By cogeek in forum C Programming
    Replies: 4
    Last Post: 12-23-2004, 06:40 PM
  4. switch{}
    By Draco in forum C Programming
    Replies: 1
    Last Post: 05-04-2003, 10:11 AM
  5. can (switch) be apart of a loop?
    By matheo917 in forum C++ Programming
    Replies: 2
    Last Post: 09-20-2001, 06:29 PM