Re: cin - Why Does It Require 2 Returns?
On 8/22/2011 3:45 PM, Stefan Ram wrote:
Ian Collins<firstname.lastname@example.org> writes:
Until the program grows and the user wonders why the line does not appear.
A: ?Why should I use X in this program??
B: ?You do not actually need it in this program.
But if you would write another program, you would need it.
So you'd better start using it right now, should your
program ever be changed somehow into that other program.?
A: ?Why should I take the drug X??
B: ?Well you do not need it right now. But if you ever should
develop the condition S, you would need it. Therefore, you
should better start to take it now, so that you will not
forget to take it, if you ever develop that condition.
Even, if the drug makes your movements become
a little bit slower now.?
To summarise all recommendations, in a debug version every output should
be followed by a flush (otherwise the output can be lost when debugging
with breakpoints or due to a crash), and any time the designer of the
program expects the user to want to see the output, some kind of flush
needs to happen, especially when the user input is required. Correct?
The latter is often taken care of by synchronising intput and output.
And the former could be done based on timer.
For debugging, some kind of built-in automatic flushing after every
output would be very handy. OTOH, when debugging I/O buffering one
should explicitly disable the automatic flushing...
Any other times when a flush would be necessary or ill-advised?
I do not respond to top-posted replies, please don't ask