64,650
社区成员
发帖
与我相关
我的任务
分享
int _tmain(int argc, _TCHAR* argv[])
{
int val;
ifstream ifile("1.dat");
while (ifile >> val, !ifile.eof())
{
if (ifile.bad())
throw runtime_error("IO System Error.");
if (ifile.fail())
{
cerr << "bad val, try again";
ifile.clear(ifstream::failbit);
ifile.ignore(20, ' ');
continue;
}
cout << val;
}
return 0;
}
int main()
{
int val;
ifstream ifile("1.dat");
while (ifile >> val, !ifile.eof())
{
if (ifile.bad())
throw runtime_error("IO System Error.");
if (ifile.fail())
{
ifile.clear();
ifile.ignore(20, ' ');
continue;
}
cout << val << " ";
}
return 0;
}