我正在做作业,并被此错误困扰。我编码为通过从客户ID中搜索来从.txt数据库中获取客户详细信息。但这不起作用。它仅显示第一个条目。其他人没有搜索。我需要在以下代码中更正哪里。
int count = 0;
string SearchCusAccNum, SCAN1, SCTN1, SCN1, SCA1, SCCT1, SCICT1, SCCLI1, SCOD1;
cout << "\nEnter the account number : ";
cin >> SearchCusAccNum;
ifstream SearchCAN("CusDetail_DB.txt");
while (SearchCAN >> SCAN1 >> SCN1 >> SCA1 >> SCTN1 >> SCCT1 >> SCICT1 >> SCCLI1 >> SCOD1)
{
if (SearchCusAccNum == SCAN1)
{
count = 1;
}
SearchCAN.close();
if (count == 1)
{
cout << "Customer account number : " << SearchCusAccNum;
cout << "\nCustomer name : " << SCN1;
cout << "\nCustomer address : " << SCA1;
cout << "\nCustomer Telephone Number : " << SCTN1;
cout << "\nCustomer connection type : " << SCCT1;
cout << "\nCustomer internet connection type : " << SCICT1;
cout << "\nCustomer CLI facility : " << SCCLI1;
cout << "\nCustomer other details : " << SCOD1;
cin.get();
cin.get();
system("cls");
DisplayAccData();
}
else
{
cout << "\nSorry, Account number is not founded in the database\n";
cin.get();
cin.get();
system("cls");
DisplayAccData();
}
}