文件複製操作

//文件複製操作.cpp
#include<iostream.h>
#include<fstream.h>  //有關文件輸入、輸出的定義文件
#include<stdlib.h>

void main()
{
 char ch;
 fstream inf,outf;
 inf.open("d://temp//filein.txt",ios::in);
 if(!inf){
  cout<<"It cannot open the file!"<<endl;
  abort();
 }

outf.open("d://temp//fileout.txt",ios::out);
if(!outf){
 cout<<"It cannot open the file!"<<endl;
 abort();
 }

while(!inf.eof()&&inf.get(ch)){
 //inf.get(ch);//按字符讀取文件filein.dat的數據
 outf.put(ch);
 }// 將數據按字符寫入文件fileout.dat中

inf.close();
outf.close();
}

發佈了36 篇原創文章 · 獲贊 0 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章