登录信息和密码确认不起作用c ++

时间:2015-12-06 21:26:25

标签: c++ while-loop passwords registration

我正在尝试制作用户注册类型的程序。我希望用户注册输入登录名,密码和确认密码。然后,在完成后,他们在主菜单中选择一个选项,我希望用户通过验证他们的详细信息(登录名和密码)来登录。到目前为止,我有两个函数,但由于某些原因,当他们输入密码登录时,即使密码匹配,程序也会输出错误的密码"消息:

string login_information(string login, string set_password, string confirm_password)
{

cout<<"Please enter the login: ";
cin>>login;
cout<<"Please create your password: ";
cin>>set_password;
cout<<"Please confirm password: ";
cin>>confirm_password;
while (set_password!=confirm_password)
{
    cout<<"passwords do not match"<<endl<<"Please confirm password: ";
    cin>>confirm_password;
}
if (set_password==confirm_password)
    cout<<"Registration complete"<<endl;    
system("pause");
system("CLS");
return confirm_password;
}

void password_protection(string confirm_password, string password_input)
{
cin >> password_input;
while (password_input!=confirm_password)
{
    cout << "Incorrect password, please re-enter password: "<<endl;
    cin>>password_input;
}
if (password_input==confirm_password)
    cout<<"Authorised."<<endl;
}

0 个答案:

没有答案