65,210
社区成员
发帖
与我相关
我的任务
分享
string strBuf;
ifstream is("1.txt", ios::in); // 1.txt存在
if (!is)
{
return -1;
}
while (is >> strBuf) // 一直读文件直到文件末尾
{
cout << strBuf << endl;
}
is.seekg(0, ios::beg); //设置文件读指针到开头
while (is >> strBuf) //继续读,这时好像读不了了。
{
cout << strBuf << endl;
}
is.clear();
is.seekg(0, std::ios::beg);
