1. Create a copy of an existing file and open it.
2. Name the copy with the current date and time.
str = date and time as a string
path = the destination to my file + str + the extension "docx" because I need a Word file
How can I pass the path created that way to the ofstream outputFile() in order to create the copy of the original document with the name I want to ?
The filename using date/time is ok but for two problems. The character ':' is not permitted. The use of a 12-hour clock could result in a non-unique name, I'd recommend a 24-hour clock.
Also the use of functions can simplify the code, at least it breaks it down into reusable pieces.
Your file copy using an intermediate buffer is ok, though you might consider an alternative. Much of the code below is error handling and message output: