Answer the question
In order to leave comments, you need to log in
How to not continue executing the body of the loop for certain user input?
I'm writing a small console program for myself (password generator). I have this piece of code:
else if (answer == "NO" || answer == "no" || answer == "No" || answer == "nO")
{
system("cls");
cout << "Generating passwords... " << endl << endl << endl;
for (int i = 0; i < quantity; i++)
{
cout << "\nNumber of characters of the password №" << i + 1 << ": ";
cin >> length;
if (length < 8)
break;
else
{
cout << endl;
for (int j = 0; j < length; j++)
{
cout << possible_characters[rand() % size];
}
cout << endl << endl;
}
}
}
Answer the question
In order to leave comments, you need to log in
Decision:
while(1){
//code
int answer;
cin<<a;
if(a<8){
break;
}
std::cout>>"Wrong answer!!!\n"
}
if(answer in ["NO","no"",No"","nO"]){
//code...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question