I'm opting to get acclimcated with the remove and replace functions with regards to file systems. Lets supposed I have a file excercise15.txt. I'll copy exercise15.txt to testfile.txt. In theory I'd like to duplicate exercise15.txt 10 times. So now I'd have
testfile1.txt .... testfile10.txt. How do I achieve that?
Here's my thougths thus far but I'm unsure how to integrate the "RenameFile function" with the rest of the program. Program currently dumps contents of exercise15.txt to a file testfile.txt.
void RenameFile( const std::string& OldName, const std::string& NewName )
if( !std::rename( OldName.c_str(), NewName.c_str() ) == 0 )
throw std::runtime_error( "Could not rename " + OldName + "." );
int main(int argc, char* argv)
ifstream inFile ("exercise15.txt");
fstream outFile ("testfile.txt");
outFile << inFile.rdbuf();
// Print the contents of the input file.
// ostream_iterator<string>( cout, "\n" ) );
// "Print" the contents of the output (ToFile) file
//std::cout << outFile.rdbuf(); //or use std::copy