I am trying to make a program which asks you to enter password and when u enter the correct password it will say ‘Access Granted.’ and if u enter a wrong password it will say ‘Access Denied’ and ask u to enter the password till u get it right. I can do it without using countinue and by using break. Code is given below.
#include <iostream>
using namespace std;
int main() {
const string password = "love";
string input;
do {
cout << "Enter Your Password > " << flush;
cin >> input;
if (input == password) {
continue;
} else {
cout << "Access Denied." << endl;
}
} while (true);
cout << "Access Granted." << endl;
cout << "Program Quitting..." << endl;
return 0;
}
Source: StackOverflow C++