I'm extremely new to C++, and can't really figure this out. I've tried a couple things, but I feel like I'm just missing something simple.
I have this console application where a user inputs a pre-defined password. If the password is incorrect, it prompts them to re-enter the password. If the password is correct, is simply ends the program, but I want it to say "Access granted!" then end.
A side issue I'm having is when more than word is entered as the password, "Access Denied" is printed for each word.
string password;
cout << "Please enter the password!" << endl;
cin >> password;
if (password == "test") {
cout << "Access granted!";
} else {
do {
cout << "Access denied! Try again." << endl;
cin >> password;
} while (password != "test");
}
return 0;