A possible way to copy files in C++ is to learn then use some existing C++ library or framework, like Qt or POCO.
Another way is to use C++ std::string
-s, documented here to build your command line.
Newer C++ standards have std::filesystem
documented here.
Of course, you will spend days in reading documentation.
My recommendation is to read the documentation of your C++ compiler (e.g. GCC, that you might invoke as g++ -Wall -Wextra -g
- all warnings and debug info). Then read the documentation of your debugger (e.g. GDB).
You probably also want to read the documentation of your version control system (e.g. git).
Notice that your code (even improved a bit) won't work on my computers (they all run Linux), since copy
(as a program) does not exist on them. The near equivalent program is called /bin/cp
part of GNU coreutils.
I heard that copy
is a Windows specific program. It existed on MSDOS.
At last, some computers (e.g. RaspberryPi) might be programmable in C++ and not even have any files.