Newbie question: How to "save as" an existing text file

This is a discussion on Newbie question: How to "save as" an existing text file within the C++ Programming forums, part of the General Programming Boards category; Can someone please help me on this?
I need to make a copy of an existing .txt file and save ...

Newbie question: How to "save as" an existing text file

Can someone please help me on this?

I need to make a copy of an existing .txt file and save it under a different name. The original file needs to be preserved so a simple "rename" can't do the trick. I've been searching on the web and the only way I found was to read the existing file into some sort of a data structure, e.g. vector<string>, then dump the whole thing into a new .txt file.

I'm a bit concerned that the files are pretty big so is there a better way of doing this, please? Many thanks.

If its a programming practice. You create a memory buffer. Load data into it. Save it somewhere else or with a different name. If the file does not fit in memory, do the same thing in a loop to copy whole of it.

If its a programming practice. You create a memory buffer. Load data into it. Save it somewhere else or with a different name. If the file does not fit in memory, do the same thing in a loop to copy whole of it.

Under windows (which is the system where examples in preceding posts will typically work) the win32 SDK has a function named CopyFile() that will have the required effect. Catch is, that is also non-portable (only works on Microsoft operating systems).

If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.