【发布时间】:2014-06-30 05:23:38
【问题描述】:
void ReadTheData(ifstream& in_stream, ofstream& out_stream)
{
using namespace std;
int id;
char name[100] = "";
double balance;
in_stream >> id >> name >> balance;
while(name[0] || ! in_stream.eof()) // Continue looping until eof or name is not present.
{
cout << id << '\t' << name << '\t' << balance << endl;
in_stream >> id >> name >> balance;
}
}
the Balance.txt has format style:
4248749 Kelly_E 460.02
8898693 Kelly_George_MD 1764.68
4597789 Lambert_Richard 1571.79
当我运行代码时,文件 Balance.txt 中的最后一行进入了无限循环,如何停止无限循环?
【问题讨论】: