I'm Trying to make a program that copys files and pastes them in the same folder. I got that far but i want the copyed file to be... hard to explin here is and example.
EXAMPLE:
Copyed File: C: example.exe
i want it to look like this:
C: example1.exe
i want to do that without entering it into the code.
im not very good at explaining stuff but ill give it a go:
first it creates a stringstream called "stream" -used for converting string to int or int to string; you need to include <sstream>
then create output file stream called "output" -used for outputing to files
you need to include <fstream>;
then creates a string called "filename" to store what we want the file to be called and a string called 'x' so we can put the converted int into x; you need to include <string>;
and then crates an int called 'i' to use in the loop and to name the file;
then we start the main() function and streight away start a "while loop"
so while the int i is less than 10 it will continue to loop;
i++ //increases i by one
stream << i; // outputs i to the stringstream object
stream >> x; // inputs converted int i to x so x will contain whatever i was but as a string;
stream.str(""); // emptys the stringstream
stream.clear(); // clears bit flag (im not to sure what this part is for but i have been tought to do it like this);
filename ="C:\\example" + x + ".txt"; //makes filename contain
"C:\example(whatever x is).txt"
cout << filename <<endl; //outputs to to screen whatever filename is;
output.open(filename.c_str()); makes output
"C:\example(whatever x is).txt" and opens it for output or creates it if it is not already there;
output << "."; // outputs to file "." so that the file contains '.';
output.close(); // closes the filestream;