【发布时间】:2016-03-10 01:57:46
【问题描述】:
我这样调用函数getseconddata (list2,n)
输入文件读取
45 P 19
11 S 56
45 S F
30 P F
函数代码读取
void getseconddata(employeetype list2[], int n)
{
ifstream infile2;
string filename;
int id, changenum;
char stat, changealpha;
cout<<"Enter name of second data file"<<endl;
cin>>filename;
infile2.open(filename.c_str());
infile2>>id;
while (getline(infile2))
{
infile2>>stat;
if (stat=='S')
{
infile2>>changealpha;
}
else if (stat=='P')
{
infile2>>changenum;
}
infile2>>id;
}
infile2.close();
for (int i=0; i<n; i++)
{
cout<<id<<stat<<changealpha<<changenum<<endl;
}
}
输出读取
45 P 19
45 P 19
45 P 19
45 P 19
我已经尝试重写代码并在线查找基本功能和eof。帮助
【问题讨论】:
标签: c++ function if-statement while-loop ifstream