#include <stdio.h>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream in;
in.open("b.cpp");
string temp;
while (getline(in, temp))
{
cout << temp << endl;
}
in.clear();
in.seekg(0, ios::beg);
while (getline(in, temp))
{
cout << temp << endl;
}
return 0;
}
要注意clear函数的使用!