Re: cin - Why Does It Require 2 Returns?
On Aug 22, 7:13 am, Juha Nieminen <nos...@thanks.invalid> wrote:
Ian Collins <ian-n...@hotmail.com> wrote:
using endl rather then \n would be better.
That's a bad advise to give just like that. Newbies will then
start using it *everywhere* and have their programs heavy in
I/O slow down to a crawl.
Unless the programmer understands buffering, and what it does,
he should use std::endl. It's just too hard to debug a program
when you don't know where it crashed, because part of your
output hasn't appeared.
When you give the advise, you have to explain *why*. Also
explain when it's better to use "\n".
The only time it's "better" to use "\n" is if your program runs
too slowly otherwise. There are a number of times where it
really doesn't matter, and I'll use "\n" in the middle of a
number of closely spaced output, especially if I'm outputting
several lines in a single expression. (But then, I'm not really
a newby when it comes to ostream, so I can allow myself this
sort of luxury.)
--
James Kanze