"utab" <um********@gmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
: Hi there,
:
: I am copying one file into another file character by character.
:
: I wanted to learn if there is a faster way of doing this?
:
: When files get bigger, maybe this can take a lot of time.
:
: Thanks for the replies in advance.
For C++ streams, the easy way to copy one stream to another
is to send the source's streambuf to the output:
// #include <fstream>
std::ifstream src("source.txt");
std::ofstream dst("destination.txt");
dst << src.rdbuf();
This should perform faster than a character-by-character copy,
but actual performance is implementation-dependent.
Of course there is always a faster/more complicated/less portable
way to implement this operation.
hth -Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <>
http://www.brainbench.com