![]() |
#2
rjsp2016-06-24 18:42
|

void lookup_num() //按学号查询
{
char a;
ifstream ist(filename.c_str());
if(!ist)
{
cout<<"读取信息失败"<<endl;
exit (0);
}
string line;
string num1;
string num;
string oo="学号:";
while(1)
{
cout<<"请输入要查询学生的学号:";
cin>>num1;
num=oo+num1;
while(!ist.eof())
{
getline(ist,line);
if(strstr(line.c_str(),num.c_str())!=NULL)
{
cout<<"该学生信息为:"<<line<<endl;
}
}
cout<<"是否继续 1.继续查找 2.返回主菜单"<<endl;
cin>>a;
system("cls");
if(a=='1') continue;
if(a=='2') break;
}
a='0';
ist.close();
}
{
char a;
ifstream ist(filename.c_str());
if(!ist)
{
cout<<"读取信息失败"<<endl;
exit (0);
}
string line;
string num1;
string num;
string oo="学号:";
while(1)
{
cout<<"请输入要查询学生的学号:";
cin>>num1;
num=oo+num1;
while(!ist.eof())
{
getline(ist,line);
if(strstr(line.c_str(),num.c_str())!=NULL)
{
cout<<"该学生信息为:"<<line<<endl;
}
}
cout<<"是否继续 1.继续查找 2.返回主菜单"<<endl;
cin>>a;
system("cls");
if(a=='1') continue;
if(a=='2') break;
}
a='0';
ist.close();
}