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;
}