Thread: Bug in my barely-started text-based game program

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    91

    Help needed with a text-based game program

    Here's the code, explanation of what's wrong at the moment at the bottom.

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    
    using namespace std;
    
    int main () {
        string select;
        
        cout << "Welcome to Link's Grand Quest!\n";
        cout << "Select an option:" << endl << endl;
        cout << "Create Character (press c)\n";
        cout << "Load Character (press l)\n";
        cout << "Creator (press r)\n";
        cout << "Exit (press e)\n";
        cin.ignore(80, '\n');
        cin >> select;
        if (select == "c" || select == "C") {
                   cout << "I'm sorry, this feature is not available yet";
        }
        else if (select == "l" || select == "L") {
             cout << "I'm sorry, this feature is not available yet";
        }
        else if (select == "r" || select == "R") {
             cout << "I'm sorry, this feature is not available yet";
        }
        else if (select == "e" || select == "E") {
        }
        else {
    //         while (select != "c" || select != "C" || select != "l" || select != "L" || select != "r" || select != "R" || select != "e" || select != "E") {
    //               cout << "I'm sorry, you did not select an option. Please select from below:\n\n";
    //               cout << "Create Character (press c)\n";
    //               cout << "Load Character (press l)\n";
    //               cout << "Creator (press r)\n";
    //               cout << "Exit (press e)\n";
    //               cin >> select;
    //               if (select == "c" || select == "C") {
    //                          cout << "I'm sorry, this feature is not available yet";
    //               }
    //               else if (select == "l" || select == "L") {
    //                    cout << "I'm sorry, this feature is not available yet";
    //               }
    //               else if (select == "r" || select == "R") {
    //                    cout << "I'm sorry, this feature is not available yet";
    //               }
    //               else if (select == "e" || select == "E") {
    //                    cout << "I'm sorry, this feature is not available yet";
    //               }
    //               else {
    //               }
    //         }
        }
        cin.get();
    }
    I commented out the parts I don't want running in the program for now, and the bug still exists, so I know the bug resides somewhere in the first cin >> select;'s area. When I type "c", it doesn't output a single thing, and you have to input something else (although enters don't seem to work) to get the program to close after that point. No matter what I use on cin >> select;, it does this. Any help?
    Last edited by linkofazeroth; 08-27-2005 at 10:51 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 19
    Last Post: 05-30-2007, 05:47 PM
  2. PC Game project requires c++ programmers
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 02-22-2006, 12:23 AM
  3. making a text based game
    By MisterSako in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2004, 01:20 PM
  4. Creating Shell based game..Few questions
    By Saintdog in forum Game Programming
    Replies: 1
    Last Post: 12-01-2004, 08:14 PM
  5. My Memory Game
    By jazy921 in forum C Programming
    Replies: 0
    Last Post: 05-05-2003, 05:13 PM