c++读写文件

三个流 ifstream (读) ofstream(写) fstream(读或写)
把一个文件复制到另一个文件
char hy;
ifstream fin("D:\test.txt");
if(!fin)
{
cout<<"cannot open input file"<<endl;
}
cout<<"open "<<endl;
ofstream fout("D:\test1.txt");
if(!fout)
{
cout<<"cannot open output file"<<endl;
}
cout<<"open "<<endl;
while(fin.get(hy))
{
cout<<hy<<endl;
fout.put(hy);
}

posted @ 2018-10-27 13:05  七月的四字  阅读(109)  评论(0编辑  收藏  举报