From: Keith M. <kei...@to...> - 2006-02-24 16:18:42
|
Greg Chicares wrote: > Here's an MSYS-without-rxvt session: > > $cat hello_world_no_flush.cpp > #include <iostream> > > int main() > { > std::cout << "Hello, world!"; > } > $/c/MinGW-20050120/bin/g++ hello_world_no_flush.cpp > $./a > Hello, world!$ > > which can be seen as a cockpit error (no newline, no flush), With respect Greg, that's perfectly correct behaviour, (and it's exactly what I see with identical code, on my GNU/Linux box). By default, stdout is *line* buffered, so an automatic flush should occur when you emit a newline. But your code never emits a newline, so what you see is your output automatically flushed on process termination, followed by the shell prompt; there's no intervening newline, because *you* omitted it -- if you want it, then you need: std::cout << "Hello, world!\n"; or, perhaps std::cout << "Hello, world!" << std::endl; Your zsh example is more puzzling though. Perhaps the shell returns the cursor to the leftmost column, without a line advance, and issues a `delete to end of line' request, before issuing the prompt? That would flash the output very briefly, perhaps too briefly to even see, then immediately erase it before displaying the next prompt. Regards, Keith. |