I used an if and else statement, and I want the user to answer it, like, if answer = yes {do this} while the user inputs the yes.
But after I ask the question, and the user does the input, the question goes into an infinite loop and repeats the question while also cutting out the last character and replacing it with a number% because I used that as the if statement. after every answer the number goes up by one.
I want the question to not repeat and use the correct output. how do I do this?
I have tried to end the loop using the break; statement, it did not work.
cout << "\n\nWould you like to Download file?\n";
Sleep (500);
cout << "'yes' is the only correct way to agree.\n\n"<<endl;
cin>>answer;
if (answer=="yes"){
cout << "Downloading file.";
Sleep(500);
cout << ".";
Sleep(500);
cout << ".\n";
{
std::cout << "a%";
int m = 0;
for (int i = 0 ; i < 101 ; i++) {
for (int j = 0; j < std::to_string(m).length()+1; j++)
std::cout << '\b';
std::cout << i <<'%'<< std::flush;
Sleep(95);
m = i;
}
}
}
else;{
cout << "Alright, no file for you.";
}
Aucun commentaire:
Enregistrer un commentaire