我想创建一个程序,用户输入一组特定的字符数,然后检查已创建的文件,如果它在每行中都有用户键入的完全相同的字符。
我的代码:
[ServiceContract]
public interface IWcf.BLL
{
[OperationContract]
string Register(RegistrationList Login); // Here I can set type as `RegistrationList`
}
我的employees.txt文件包含:
string line;
string employeeID;
bool found = false;
ifstream stream1("employees.txt", ios::app);
do{
cout << "Enter Employee Password:" << endl;
getline(cin, employeeID);
while (!stream1.eof())
{
getline(stream1, line);
if (employeeID == line){
found = true;
}
}
} while (found == false);
修复后的代码:
ADH4172
DGGH481
答案 0 :(得分:0)
while (found=false)
将found
设置为false
,使条件为false,因此循环立即终止。将其更改为`found == false&#39;。