-3
do while 루프에서도 무한 루프가 계속됩니다!무한 루프가 계속 끝나는 이유는 무엇입니까?
내가 뭘 잘못하고 있니? 나는 모든 것을 시도했다. 그러나 나는 그것을 아직도 이해할 수 없다. 어떤 도움?
#include <iostream>
#include <string>
#include <Windows.h>
using namespace std;
//function prototypes
//prototype for IsAccessible
int IsAccessible(string username, string password);
//prototype for menu
void menu();
int main()
{
string username;
string password;
//make user to login
cout << "Enter username : ";
getline(cin, username);
cout << "\nEnter Password : ";
cin >> password;
IsAccessible(username, password);
cout << "Thank you for logging in!!";
cin.ignore();
cin.get();
return 0;
}
//function definitions
//definition for IsAccesible
int IsAccessible(string username, string password)
{
//check if user entered correct details
do
{
int x = 0;
if(password == "123" && username == "asdqw")
{
cout << "\n\nThank you for loggin in John!";
break;
}
//if user entered wrong details
else if(password != "123" && username != "asdqw")
{
cout << "\nYou have either entered a wrong password or username.\n";
cout << "Please retry.";
}
//if user exceeds limitation
if(x == 5)
{
cout << "\n\nYou have exceeded the 5 retry limitations......\n";
Sleep(4000);
cout << "Exiting program....";
Sleep(5000);
return 0;
}
}while(password != "123" && username != "asdqw");
return 0;
}
어디에서 while 루프에 입력합니까? –
'cin >> password;를해야합니다.' 루프를 끝내려면 루프에 넣으십시오. – yakoudbz
나는 THX를 어떤 방식 으로든 고쳐 놓았다. – user2782625