Thread: Another Noob Question

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    16

    Another Noob Question

    Is it possible to do a case within a case? For example:

    Code:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        int y;
        int x;
        int a;
        int b;
        cout << "Selection:\n";
        cout << "1. Start\n";
        cout << "2. LoL\n";
        cout << "3. Quit\n";
        cout << "Please make your selection: ";
        cin >> y;
    switch (y) {
      case 1:
           switch (x) {
                  case 1:
                       break;
                  case 2:
                       break;
                  case 3:
                       break;
                  case 4:
                       break;
                  default:
                       cout << "Invalid input.\n";
                       break;
                       }
                       
        break;
      case 2:
        cout << "\nWrong Button!\n\n";
        break;
      case 3:
        return 0;
        break;
      default:
        cout << "\nInvalid input.n\n";
      }
        system("PAUSE");
    }
    I have actual things filled in, in the sub-cases, but it doesn't prompt me with a 2nd selection. It just skips to the "Invalid Input" portion

    Edit: Hope I indented it right. Feel free to yell at me if I didn't.

    Edit Edit: A simple yes or no would suffice; however, if no a suggested alternative method would be extremely appreciated.
    Last edited by Nightwarrior; 10-12-2007 at 08:53 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. quick noob question
    By thanatos1 in forum C# Programming
    Replies: 2
    Last Post: 06-17-2009, 08:28 PM
  2. another noob question
    By clb2003 in forum C Programming
    Replies: 4
    Last Post: 02-12-2009, 01:28 PM
  3. Noob printf question
    By lolguy in forum C Programming
    Replies: 3
    Last Post: 12-14-2008, 08:08 PM
  4. Very noob question :(.
    By GamerProduction in forum Tech Board
    Replies: 4
    Last Post: 04-14-2007, 05:40 AM
  5. Noob question ( little dos program )
    By Demon1s in forum C++ Programming
    Replies: 13
    Last Post: 04-04-2003, 09:28 PM