出现错误后需要帮助重置密码
Need help resetting the password after getting an ERROR
大家好,我只是想知道在输入无效输入后,我应该在哪里以及如何重置密码。例如,在用户收到错误后输入正确的密码后,它会使用正确的密码进行复制。因此,当用户在密码中输入"空格"时,当错误触发时,它会不断给我一个错误,即即使没有空格,我的输入仍然有空格。
enter code here
do
{
int i = 0;
flag = true;
cin.clear(); // reset the input stream
cout << "Enter your passwordn";
ch = _getch();
while(ch != 13)
{//character 13 is enter - carriage return
pass += ch;
cout << '*';
ch = _getch();
}
cout << "nThe password you entered was " << pass << endl;
cin.clear(); // reset the input stream
while (i < pass.length() && flag)
{
if (pass.at(i) == ' ')
{
cerr << "ERROR: PASSWORD CANNOT CONTAIN ANY SPACES!" << endl;
flag = false;
}
i++;
}
if (pass.length() < 5)
{
cerr << "ERROR: PASSWORD IS TOO SHORT!" << endl;
flag = false;
}
cout << endl;
}
这将起作用:
string pass;
bool flag;
do
{
flag = true;
cout << "Enter your passwordn";
getline(cin, pass);
cout << "Pass is " << pass << endl;
unsigned int i=0;
while (i < pass.length() && flag)
{
if (pass.at(i) == ' ')
{
cout << "ERROR: PASSWORD CANNOT CONTAIN ANY SPACES!" << endl;
flag = false;
}
++i;
}
}while(flag == false);
相关文章:
- 需要帮助设置在C++中使用的Potrace
- 在指针的帮助下,文本文件中单词的频率
- 计算每个节点的树高,帮助我解释这个代码解决方案
- 如何在Qbutton的帮助下更改Q对话框的宽度
- 需要帮助将结构数组传递给函数
- C++需要帮助从用户那里获得一个整数,并确保它在另外两个整数之间
- c++中的oop(密码生成)
- 密码登录程序将永远循环并显示不正确的结果
- OpenSSL没有共享密码
- 需要帮助在 c++ 中将字符串转换为字符 ----错误 "const char *" 类型的值不能用于初始化 "char" 类型的实体
- 有人可以帮助我处理正则表达式吗?
- C++调用具有 *this 属性的单个帮助程序函数
- Cryptopp:获取密码输入的填充字符串
- C++:需要帮助了解运算符重载错误
- 需要以下代码的帮助,下面的代码有什么问题
- CS1 项目帮助C++
- QFile和QTextStream帮助(为具有用户名、密码和名称的用户编写ID)
- 密码计数帮助
- 出现错误后需要帮助重置密码
- visual c++帮助,密码验证器