#include<iostream>
#include<fstream>
using namespace std;
ofstream writeData;
writeData.open("data.txt", fstream::out | ios_base::trunc); // ios_base::trunc 表示清空文件数据
ifstream readFile;
readFile.open("data.txt", ios::in); // 在vc6中的MFC工程中, 需要定义成ios::in
readFile.open("data.txt",, ios::app);在decv中,cpp文件
string str,temp;
while(getline(readFile,str))
{
temp = str;
}
str为空,temp为文件中最后一条数据