// Hangman Redo Program
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <string>
#include <algorithm>

using namespace std;

//Functions
void welcome();
void instructions();
void game();

// Types and Arrays
string choice;
string inst;
	


int main()
{
	welcome();

	return 0;
}
void welcome()
{
	cout << "\tWelcome to Hangman 2.0 By Khoanyneosr!" << endl;
	cout << "Would you like to see the instructions?";
	cout << endl << "Yes - Y" << endl;
	cout << endl << "No - N\n- ";
		cin >> choice;

		transform(choice.begin(), choice.end(), choice.begin(), toupper); // toupper algorithm
		cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' ); // limit cin
	bool done = false;
	while (done = false)
	{

		if (choice == "Y")
		{
			instructions();
			done = true;
			break;
		}
		else if (choice == "N")
		{
			game();
			done = true;
			break;
		}
		else
		{
			cout << endl << "Invalid input.\n- ";
			done = true;
			continue;

		}
	};


}
void instructions()
{
	cout << endl << "Instructions()" << endl;
}
void game()
{
	cout << endl << "Game();" << endl;
}

That's my code. For some reason when i try to enter either Y or N it just ends the loop then shuts down and doesn't continue to where i want it to go. What am i doing wrong here? thanks in advance.

Recommended Answers

All 2 Replies

Because while (done [B]=[/B] false) sets done to FALSE, so your test is FALSE.

>while (done = false)
That = is not the same as == issue has been coming up a lot recently. Your loop condition is always going to fail because now done is false and that's the result of the expression.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.