Helpful Ideas to get started

This is a discussion on Helpful Ideas to get started within the C++ Programming forums, part of the General Programming Boards category; okay last question and i think i got it why does it say i'm "jumping to case label" whenever i ...

  1. #16
    Registered User
    Join Date
    Dec 2009
    Posts
    19
    okay last question and i think i got it why does it say i'm "jumping to case label" whenever i add case 2: into this

    Code:
    #include<iostream>
    #include<ctime>
    #include<cstdlib>
    #include<string>
    
    using namespace std;
    
    int length, index1, index2, input, num, i, tries = 0;
    string guess; 
    char temp;
    char SYMBOLS[4] = {'!', '&', '@', '%'};
    
    
    void Seed()
    {
         srand(time(0));
    }
    int GetRandNum(int max)
    {
     return rand() % max;    
    }
    
    int main()
    {
    
    Seed();
     
    while((input != 1) && (input != 3))
    {
    cout << "Welcome to the game of Logic!" << endl;
    cout << "What would you like to do?" << endl << endl;
    cout << "1 - Play the game of Logic" << endl;
    cout << "2 - Read instructions on how to play Logic" << endl;
    cout << "3 - Quit" << endl;
    cin >> input;    
       
        
    switch(input)
    {
          case 1:
               
               cout << "Enter the number of symbols you would like to guess" << endl;
               cin >> length;
               
             
              string sequence = ""; 
                   
              for (i = 0; i < length; ++i)
              {
              
              num = GetRandNum(3);
              sequence += SYMBOLS[num]; 
              }
              cout << sequence << endl;
             do
             {
                   
             cout << "Guess the order in which the symbols are in" << endl;
             cin >> guess;
                           
             if (guess != sequence)
             {
             ++tries;
             cout << "Try again" << endl;
             cout << "Tries: " << tries << endl;
             }
             else
             {
             cout << "You got it!" << endl;
             }
              
             }
             while (guess != sequence); 
             system("PAUSE");
             break;
    
         case 2:
               
               cout << "Choose the number of symbols you wish to be in the puzzle" << endl;
               cout << "Then determine the order in which the symbols are placed" << endl;
               cout << "Press any key to return the main screen" << endl << endl << endl;  
               
               system("PAUSE");
               system("CLS");
               break;
    
    }
    }
     system("PAUSE");  
     return 0;
      
    }

  2. #17
    Registered User
    Join Date
    Dec 2009
    Posts
    19
    Code:
    #include<iostream>
    #include<ctime>
    #include<cstdlib>
    #include<string>
    
    using namespace std;
    
    int length, index1, index2, input, num, i, tries = 0;
    string guess; 
    char temp;
    char SYMBOLS[4] = {'!', '&', '@', '%'};
    
    
    void Seed()
    {
         srand(time(0));
    }
    int GetRandNum(int max)
    {
     return rand() % max;    
    }
    
    int main()
    {
    
    Seed();
     
    while((input != 1) && (input != 3))
    {
    cout << "Welcome to the game of Logic!" << endl;
    cout << "What would you like to do?" << endl << endl;
    cout << "1 - Play the game of Logic" << endl;
    cout << "2 - Read instructions on how to play Logic" << endl;
    cout << "3 - Quit" << endl;
    cin >> input;    
       
        
    switch(input)
    {
          case 1:
               
               cout << "Enter the number of symbols you would like to guess" << endl;
               cin >> length;
               
             
              string sequence = ""; 
                   
              for (i = 0; i < length; ++i)
              {
              
              num = GetRandNum(3);
              sequence += SYMBOLS[num]; 
              }
              cout << sequence << endl;
             do
             {
                   
             cout << "Guess the order in which the symbols are in" << endl;
             cin >> guess;
                           
             if (guess != sequence)
             {
             ++tries;
             cout << "Try again" << endl;
             cout << "Tries: " << tries << endl;
             }
             else
             {
             cout << "You got it!" << endl;
             }
              
             }
             while (guess != sequence); 
             system("PAUSE");
             break;
    
         case 2:
               
               cout << "Choose the number of symbols you wish to be in the puzzle" << endl;
               cout << "Then determine the order in which the symbols are placed" << endl;
               cout << "Press any key to return the main screen" << endl << endl << endl;  
               
               system("PAUSE");
               system("CLS");
               break;
    
    }
    }
     system("PAUSE");  
     return 0;
      
    }
    one last thing.. why does it say that "jump to case" when i put in case 2??

  3. #18
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Ive never seen that error before. After a quick search on this site, I found this (see the first reply for the answer) Jump to Case Label error

    Also, you should initialize "input", i.e. input = 0, at the top of your program. Right now your using it without initializing it which is a bad thing. Realistically, it is unlikely to cause a problem, however it is very good practice to do this.

  4. #19
    Registered User
    Join Date
    Dec 2009
    Posts
    19
    Thanks I figured it out just wasn't putting them in brackets i guess.. Appreciate all your help

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ideas for my C++ book
    By Carlos in forum C++ Programming
    Replies: 41
    Last Post: 01-06-2004, 02:46 AM
  2. Company Name Ideas
    By brunomiranda in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 12-16-2003, 04:15 PM
  3. Maze Program, Any ideas
    By drkavngr1911 in forum C++ Programming
    Replies: 14
    Last Post: 11-13-2003, 02:32 PM
  4. 2d game ideas
    By BeholderOf in forum Game Programming
    Replies: 5
    Last Post: 10-27-2003, 05:06 PM
  5. Ideas
    By TechPhreak in forum C++ Programming
    Replies: 1
    Last Post: 10-24-2001, 09:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21