지금 Jumping into c++ 란 책을 보고 있거든요.

아래처럼 패스워드를 입력해서 4번이상 틀리면 프로그램을 빠져나오게 만들었는데...

여기서 패스워드가 맞아도 바로 빠져나오게 하고 싶은데... 방법이 없을까요?


#include <iostream>

#include <string>

using namespace std;


void pwd(string check_password)

{

if (check_password == "1234")

{

cout << "Access Allowed" << '\n';

}

else

{

cout << "Wrong password" << '\n';

}

}


int main()

{


string password;

int count = 0;

while (1)

{

cout << "Enter password: ";

cin >> password;

pwd(password);

count++;


if (count == 4)

{

break;

}

}

}