A
arnuld
this is from mentioned section. i did not understand some things here:
it means "flushing the buffer" and "writing to output device" are SAME
thing, these are just 2 different names for the same thing.
?
1st, author is saying that our program writes its /prompt/ to cout and
then he says that /cin/ flushes the buffer and that is why user sees
the prompt.
what does he mean by "our program writes the prompt" and /cin/ helps
in the user to see the prompt ?
i think i can see the prompt every time, whether i use /cout/, cin/ or
whatever.
both /cin/ and /cout/ write prompt to output device. i am utterly
confused.
To avoid the overhead of writing in response to each output request, the library
uses the buffer to accumulate the characters to be written, and flushes the buffer,
by writing its contents to the output device, only when necessary"
it means "flushing the buffer" and "writing to output device" are SAME
thing, these are just 2 different names for the same thing.
?
When our program writes its prompt to cout, that output goes into the buffer
associated with the standard output stream. Next, we attempt to read from
cin. This read flushes the cout buffer, so we are assured that our user will
see the prompt"
1st, author is saying that our program writes its /prompt/ to cout and
then he says that /cin/ flushes the buffer and that is why user sees
the prompt.
what does he mean by "our program writes the prompt" and /cin/ helps
in the user to see the prompt ?
i think i can see the prompt every time, whether i use /cout/, cin/ or
whatever.
Our next statement, which generates the output, explicitly instructs the
library to flush the buffer. That statement is only slightly more complicated
than the one that wrote the prompt. Here we write the string literal "Hello, "
followed by the value of the string variable name, and finally by std::endl.
Writing the value of std::endl ends the line of output, and then flushes the
buffer, which forces the system to write to the output stream immediately.
both /cin/ and /cout/ write prompt to output device. i am utterly
confused.