//写入
#include<fstream>
#include<iostream>
using namespace std;
int main()
{ char c=' ';
ofstream outfile("liutao.txt",ios::out);
if(!outfile){
cerr<<"open error!"<<endl;
exit(1);
}
for(;c!='\n';outfile<<c)
c=getchar();
outfile.close();
cout<<"处理完毕,请打开文件查看结果!"<<endl;
return 0;
}
//读取
#include<iostream>
#include<fstream>
using namespace std;
int main(){
fstream infile;
infile.open ("F:\liutao.txt");
char a[10];
while(!infile.eof ())
{
infile.getline (a,sizeof(a));
cout<<a<<endl;
}
infile.close ;
system("pause");
return 0;
}