When trying to copy a text file A to another file B, there may have several methods: 1) byte by byte 2) word by word 3) line by line
which one is more efficient?
Using buffers:
#include
int main()
{
std::ifstream inFile("In.txt");
std::ofstream outFile("Out.txt");
outFile << inFile.rdbuf();
}
The C++ fstreams are buffered internally. They use an efficient buffer size (despite what people say about the efficiency of stream :-). So just copy one stream buffer to a stream and hey presto the internal magic will do an efficient copy of one stream to the other.
But learning to do it char by char using std::copy() is so much more fun.