Thread: nested switch

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    115

    nested switch

    Can you have nested switch statements? Will this be just as efficient as IF-Else statements? It sure does look alot neater.

    Cheers!

    e.g
    Code:
    switch(a)
    {
    	case 1:
    	switch(b)
    	{
    		case 'm': do something;
    		break;
    	}
    .
    .
    .
    .
    .
    .
    .
    }
    there are only 10 people in the world, those who know binary and those who dont

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Yes you can nest switch statements. I think its more effective then else if statements most of the time. Their are times such as comparing multiple things at once where else if is better.

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. Help with Nested Switch
    By liquidspaces in forum C++ Programming
    Replies: 9
    Last Post: 03-28-2003, 04:08 PM
  5. nested switch
    By ccmac in forum C++ Programming
    Replies: 3
    Last Post: 04-02-2002, 09:19 PM