0
cout << endl << "\n\n\nWhat would you like to do?";
	cout << endl << " Add"
		 << endl << " View"
		 << endl << " Delete\n- ";
	cin >> todo;
	transform(todo.begin(), todo.end(), todo.begin(), toupper);
	cout << todo;
	bool done = true;
	while (!done)
	{
		if (todo == "DELETE")
		{
			system("cls");
			dlt();
			done = true;
			break;
		}
		else if (todo == "VIEW")
		{
			system("cls");
			view();
			done = true;
			break;
		}
		else if (todo == "ADD")
		{
			system("cls");
			add();
			done = true;
			break;
		}
		else
		{
			system("cls");
			mainmenu();
			done = false;
			break;

		}
	}


	return 0;
}

so thats my code. I don't understand but i can cout << todo; and it's all caps like i wanted but it wont pass todo into the while loop for some reason. does anyone know what to do?

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Fbody
0
bool done = true;
while (!done)

done is true, therefore !done is false, therefore the while loop will not execute.

0

The thing you need to remember is that, unlike some loops in some other languages, in C++ all loops execute on a true condition.

You either need to change the initialized value of "done" to false or remove the "not" ('!') from your condition.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.