Copying Binary FILE Contents Into Another

Hey guys,

How does one go about copying one binary FILE variable to another in C++?

Say I have the following:

1
2
FILE* tempFile;   //is a binary file and assume already filled with contents
FILE* localFile;


tempFile, as the name implies, is stored in a temporary directory (AND has a randomized temp name) within Windows and I want to copy its contents to another file with a predefined name that is within a valid local directory (e.g. C:\Users\user\My Documents\test.exe). What do I have to use?
Last edited on
¿do you want your temporary to remain?
If you want to move your file use `rename()'
No, I want to remove my temporary file after its done copying its contents to the other file in the valid directory.

But wow, you brought up something of big interest. Don't know why that didn't even occur to me. How do I use rename()?

And also, if I do use rename(), does it support overwriting an existing file? Like if the user already has a file with the same name in the target directory, will running the program again (with the same target specified) overwrite the one that already exists with the new one?
Last edited on
Topic archived. No new replies allowed.