#include <iostream>
#include<fstream>
using namespace std;
int main()
{
//读文件
cout << "Reading to the file" << endl;
char data[100];
ifstream infile;
//注意文件目录
infile.open("C:\\Users\\zsb\\Desktop\\aaa.txt");
while(!infile.eof()){
infile >> data;
cout << data << endl;
}
//infile >> data;
// cout << data << endl;
infile.close;
// 以写文件
cout<<"Writing to the file"<<endl;
fstream outfile;
outfile.open("C:\\Users\\zsb\\Desktop\\aaa.txt");
//定义到末尾,从末尾开始写
outfile.seekg(0, ios::end );
cin.getline(data,100);
outfile<<data<<endl;
//cin >> data ;
outfile.close;
return 0;
}