G
Guest
The following expression:
cout << "hello" << "\n";
has two properties that confuse me.
First, on the system I'm on, text file lines are terminated by newline and
carriage return (both). Why does "\n" start a new line on my system? I
suppose I could ask the same question about printf() on comp.lang.c. Isn't
line termination system dependent?
Second, my book says, very clearly:
There are three events that cause the system to flush the buffer.
First, the buffer might be full ... Second, the library may be
asked to read from stdin stream ... Third, when we explicitly say
to do so.
None of the three conditions seem to exist in the expression above. Clearly,
the buffer is not less than 5 characters wide. Not even 5 wide characters!
I'm NOT asking to read from stdin. Lastly, I didnt' explicitly say to
flush the buffer.
So exactly why does the expression above seem to flush the stdout buffer?
Thanks!
Pete
cout << "hello" << "\n";
has two properties that confuse me.
First, on the system I'm on, text file lines are terminated by newline and
carriage return (both). Why does "\n" start a new line on my system? I
suppose I could ask the same question about printf() on comp.lang.c. Isn't
line termination system dependent?
Second, my book says, very clearly:
There are three events that cause the system to flush the buffer.
First, the buffer might be full ... Second, the library may be
asked to read from stdin stream ... Third, when we explicitly say
to do so.
None of the three conditions seem to exist in the expression above. Clearly,
the buffer is not less than 5 characters wide. Not even 5 wide characters!
I'm NOT asking to read from stdin. Lastly, I didnt' explicitly say to
flush the buffer.
So exactly why does the expression above seem to flush the stdout buffer?
Thanks!
Pete