#include<iostream>
#include<fstream>
#include<string>
#include<cstdlib>
using namespace std;
int main()
string oname; cin >> oname;
ifstream fout(oname.c_str());
cout << "Enter the copy file name :";
string cname; cin >> cname;
ofstream fin(cname.c_str());
if (!fout.is_open())
{
cout << "Original file cannot be opened .\n";
exit(EXIT_FAILURE);
}
char ch;
while (fout.get(ch))
fin << ch;
cout << "OK !\n";
return 0;
}
#include<fstream>
#include<string>
#include<cstdlib>
using namespace std;
int main()
{
//输入文件夹名称的时候记得末尾带上.txt要不然文件打不开。
cout << "Enter the original file name :";string oname; cin >> oname;
ifstream fout(oname.c_str());
cout << "Enter the copy file name :";
string cname; cin >> cname;
ofstream fin(cname.c_str());
if (!fout.is_open())
{
cout << "Original file cannot be opened .\n";
exit(EXIT_FAILURE);
}
char ch;
while (fout.get(ch))
fin << ch;
cout << "OK !\n";
return 0;
}