#include <iostream>
#include <string>
int main()
bool guessedWord;
bool wantsToPlay;
char answer;
int errorCount = 0;
char userGuess;
char letter1 = '_', letter2 = '_', letter3 = '_', letter4 = '_', letter5 = '_', letter6 = '_'; // Letters to store and display the hidden characters
string hiddenWord = "BASICS";
string availableLetters = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; // Alphabet
string gallow1 = " |------|--"; // Gallows to display hangman image
string gallow2 = " | ";
string gallow3 = " | ";
string gallow4 = " | ";
string gallow5 = " | ";
string gallow6 = " ====== ";
cout << endl; // START TURN
cout << endl;
cout << gallow1 << endl; // Gallows Display
cout << gallow2 << endl;
cout << gallow3 << endl;
cout << gallow4 << endl;
cout << gallow5 << endl;
cout << gallow6 << endl;
cout << endl;
cout << endl;
// Display hidden letters and alphabet
cout << letter1 << " " << letter2 << " " << letter3 << " " << letter4 << " " << letter5 << " " << letter6 << " " << endl << endl;
cout << availableLetters << endl << endl;
cout << "Please enter your letter choice >>";
cin >> userGuess;
userGuess = toupper(userGuess);
do //plays a new game
{
do //play specific game
{
//Change guessed word or add error count,
if (userGuess == hiddenWord[0]) // checking for a match
{
letter1 = userGuess;
availableLetters[2] = '_';
}
else if (userGuess == hiddenWord[1])
{
letter2 = userGuess;
availableLetters[0] = '_';
}
else if (userGuess == hiddenWord[2])
{
letter3 = userGuess;
letter6 = userGuess;
availableLetters[36] = '_';
}
else if (userGuess == hiddenWord[3])
{
letter4 = userGuess;
availableLetters[16] = '_';
}
else if (userGuess == hiddenWord[4])
{
letter5 = userGuess;
availableLetters[4] = '_';
}
else
{
errorCount++;
if (errorCount == 1)
gallow2 += "O"; //Add a head
else if (errorCount == 2)
gallow3 += "|"; //Add a body
else if (errorCount == 3)
gallow3.at(11) = '/'; //Add a right arm
else if (errorCount == 4)
gallow3 += "\\"; //Add a left arm
else if (errorCount == 5)
gallow4 += "/"; //Add a right leg
else if (errorCount == 6)
}
} while (guessedWord == false || errorCount < 6);
if (guessedWord == true)
{
cout << "YAY!!!! YOU WIN" << endl;
}
else
{
cout << "You are dead" << endl;
}
cout << "Do you want to play again?" << endl;
cout << "Y / N" << endl;
cin >> answer;
if (answer == 'N')
wantsToPlay = false;
} while (wantsToPlay == true);
cout << "BYE" << endl;
cout << "GAME OVER....\n\n";
system("pause");
return 0;
}
This is the code I have been trying to run with the hanman project but it seems some problems are there I can't figure them out as I am very much new to programming. It would help if someone could point them out. I also have the pseudo code which our professor gave and can't figure out what to do with it. The error is showing that I have an guessedWord is uninitialised and I don;t know what it means. Hope someone can help me figure this out as soon as possible.