string username, password, usernameExist, passwordExist,
authority;
bool flag = 1;
while (flag) {
cout << "please input your username" << endl;
cin >> username;
if (!getline(account_read, usernameExist)) {
break;
}
else {
ifstream account_read("account.txt");
flag = 0;
while (true) { // 遍历账户文件看是否已经有
该名字
if (!getline(account_read, usernameExist)) {
break;
}
getline(account_read, passwordExist);
getline(account_read, authority);
if (username == usernameExist) {
cout << "the username has existed!" << endl;
flag = 1;
break;
}
}
}
}
cout << "please input your password (the min lenth of password is
6)" << endl;
cin >> password;
while (password.size() < 6) { //检测密码的长度是否大于等于 6
cout << "the password is too short" << endl;
cout << "please input your password (the min lenth of
password is 6)" << endl;
cin >> password;
}
cout << "please choose your authority ('0' is administrator
rights and '1' is general rights)" << endl;