Okay so you want to use ifstream and ofstream.
To open a certain file at a set location, you can refer to your other post but I'll copy it here:
To open file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <iostream>
#include <string>
#include <fstream>
int main()
{
std::string path = "C:\Users\Documents\Visual Studio 2017\file.txt";
std::ofstream yourFile;
if (yourFile.open(path.c_str()))
{
//do things
}
else
return 1;
return 0;
}
|
Now consider this: when you open an ofstream file in your program and the file doesn't exist at the location
you said it to open, the file is created.
So to save the file to another location, I would open the file at the location you wish, so it creates the file, and I would then
copy all the content of the first file to the second one. You would therefore have saved your first file to another location.
EDIT: Pseudocode would go like this:
*Ask user for location and name of the file you want to open
*Open file
*Ask user for location where to save file to
*Ask user for a file name for the saved file
*Open file at path with given name ->creates file
*Read content of first file and write it to second one.
*Close both files
*You're done
I hope this is clear enough and that this helps you better than last post.
Regards,
Hugo.