How can one create a function whose input is 2 strings ( representing an existing filename and a new filename respectively) And the function to be able to creat the new file which is an exact replica of the existing file?
#include<iostream>
#include<cstdlib>
#include<fstream>
#include<string>
usingnamespace std;
int main()
{
string m1;
string m2;
cout << "Enter a file to be opened for input: ";
string inFilename;
cin >> inFilename;
ifstream inFile;
inFile.open(inFilename.c_str());
inFile >> m1;
inFile >> m2;
if(inFile.fail()) //file does not exist
{
cout << inFilename << " does not exist. Please check it is in the appropriate folder.\n"; }
for (inFile.new()) // Create new file
{
cout << inFilename << "New file that is an exact replica of the existing file.\n";
}
system("PAUSE");
return 0;
}