Re: "endl and "\n"
From: Sharad Kala (no__spam.sharadk_ind_at_yahoo.com)
Date: Wed, 7 Jul 2004 13:40:55 +0530
"dover" <firstname.lastname@example.org> wrote in message
> For the code, outputfile << *p << endl;
> Someone suggests: Don't use endl here; it is flushing output stream every
> time. Use plain '\n'.
> What's the difference of using "endl" and "\n" above? What's the meaning
> flushing output stream? Isn't that what we want?
Somebody had already given you the answer ;-), it is flushing output stream
every time. Buffering here means that not everything that you write into the
stream goes to the external device, instead IOStreams is buffering (storing)
it and at some point they flush it to the external device. This boosts the
efficiency. With every endl you flush the stream which may be an overkill.