第1个回答 2012-05-13
#include <iostream>
#include<fstream>
#include <string>
using namespace std;
int main()
{
ifstream infile("TestFile.txt");
string word;
string text;
while(infile >> word);
cout << word; //word 是最后一个单词;
infile.clear();
infile.close();
infile.open("TestFile.txt");
while(getline(infile,text));
cout << text; //text 是最后一行;
return 0;
}