檔案流複製資料到檔案 , 將檔案1.txt的內容複製到2.txt 中
#include <fstream>
using namespace std;
int main(){
ifstream f1;
char ch;
f1.open("1.txt");
if (!f1)
{
cout<<"不能開啟1.txt檔案\n";return 0;
}
ofstream f2;
f2.open("2.txt");
if (!f2)
{
cout<<"不能開啟2.txt檔案\n";return 0;
}
while (f1.get(ch))
{
f2.put(ch);
}
cout<<"IS Over!\n";
return 0;
}