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?

Recommended Answers

All 2 Replies

bool done = true;
while (!done)

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

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.

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.