Thread: Need Help Just Started Programming

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    2

    Need Help Just Started Programming

    When i execute my program and run number 4 and type in the word and hit enter the script goes into an infinite loop and you can't stop it unless you exit from the program. If anyone could send me corrections to my script i would appreciate it. The script is just a guess the word game that i made for fun. Trying to understand programming....

    void TaskFive() isn't done yet i just completed the loop so that i could test and see if the program is working because i wanted it to show blanks for letters then fill them in as the user guesses the correct answer.

    The source code to the program is as fallows:

    #include <iostream.h>

    int menu();
    void TaskOne();
    void TaskTwo();
    void TaskThree();
    void TaskFour();
    void TaskFive();
    int letter, guess;
    char lword;

    int main()
    {
    bool exit = false;
    for(;
    {
    int choice = menu();
    switch(choice)
    {
    case (1):
    TaskOne();
    break;
    case (2):
    TaskTwo();
    break;
    case (3):
    TaskThree();
    break;
    case (4):
    TaskFour();
    continue;
    break;
    case (5):
    TaskFive();
    break;
    case (6):
    exit=true;
    break;
    }
    if (exit)
    break;
    }
    return 0;
    }

    int menu()
    {
    int choice;
    cout << "\n Welcome to GUESS THE WORD v 1.0 " << endl;
    cout << " Developed by David INC " << endl;
    cout << " " << endl;
    cout << " " << endl;
    cout << " ~***~ MAIN MENU ~**~ " << endl;
    cout << " " << endl;
    cout << " ( 1 ) View Readme " << endl;
    cout << " ( 2 ) Set number of guesses " << endl;
    cout << " ( 3 ) Set Letters in word " << endl;
    cout << " ( 4 ) Set Word " << endl;
    cout << " ( 5 ) Play Game " << endl;
    cout << " ( 6 ) Quit " << endl;
    cout << " " << endl;
    cout << " : ";
    cin >> choice;
    return choice;
    }

    void TaskOne()
    {
    cout << endl << " GUESS THE WORD V1.0 " << endl;
    cout << " Readme " << endl;
    cout << " " << endl;
    cout << "In order to begin playing the game you must first set\n";
    cout << "the number of guesses and the word. I'm sorry for the\n";
    cout << "inconvenience. The game is still under heavy development\n";
    cout << "I hope you enjoy the game. ";
    }

    void TaskTwo()
    {
    cout << "Please set the number of guesses: ";
    cin >> guess;
    }

    void TaskThree()
    {
    cout << "How many letters are in the word: ";
    cin >> letter;
    }

    void TaskFour()
    {
    cout << "\nWhat is the word: ";
    cin >> lword;
    }

    void TaskFive()
    {
    if (letter == 2)
    {
    cout << " WELCOME TO GUESS THE WORD v 1.0 " << endl;
    cout << " " << endl;
    cout << " " << endl;
    cout << " " << endl;
    cout << " _ _ " << endl;
    }
    else
    cout << "Sorry not done yet" << endl;
    }

  2. #2
    The Artful Lurker Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633

    Re: Need Help Just Started Programming

    Originally posted by bilbo_baggins17
    case (4):
    TaskFour();
    continue;
    break;
    Remove the continue after the call to TaskFour().
    Jason Deckard

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    2

    Re: Re: Need Help Just Started Programming

    Originally posted by Deckard

    Remove the continue after the call to TaskFour().
    i tried that but it still goes into the loop when i go into option 4 and type in the word it still goes into the loop when i hit enter

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help getting started :(
    By blackocellaris in forum C Programming
    Replies: 4
    Last Post: 11-05-2006, 06:50 PM
  2. Getting started
    By panzeriti in forum Game Programming
    Replies: 3
    Last Post: 06-28-2003, 10:13 AM
  3. Getting Started
    By UnclePunker in forum Game Programming
    Replies: 3
    Last Post: 04-11-2003, 12:34 PM
  4. How to get started?
    By anoopks in forum Linux Programming
    Replies: 0
    Last Post: 01-14-2003, 03:48 AM
  5. Need help getting started
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2001, 11:08 PM