[PLUG] C++ cout in Linux - force terminal to output partial line? - solved. flush the buffer

Greg Long plug at maneuveringspeed.com
Tue Nov 12 03:43:06 UTC 2002


Funny how sometimes all I have to do is send a request for help to
figure something out.

adding << flush; to the end of the stream does the job :)

Greg

-----Original Message-----
From: plug-admin at lists.pdxlinux.org
[mailto:plug-admin at lists.pdxlinux.org] On Behalf Of Greg Long
Sent: Monday, November 11, 2002 7:39 PM
To: PLUG
Subject: [PLUG] C++ cout in Linux - force terminal to output partial
line?


In migrating from Win to Lin, I've noticed an interesting issue:  Output
to the terminal doesn't seem to take place as the cout command sends the
stream to it, until a endl or "\n" is received.  For example,

	for(i=0;i<29;i++)
	{
		cout << i << " ";
		//(1 time delay second delay code here)
	}
	cout << "\nNow you see it.\n";

executing this could would display nothing for 30 seconds, then dump to
the terminal:

	0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25 26 27 28
	Now you see it.

a carriage return ("\r") does not do it either.

In a DOS console, output is immediate, though I can't say many other
positive things for working in a DOS terminal.  After some searching, I
am still unable to find a way to force an "ouput buffer dump" on the
terminal, so I imagine I'm attacking this from the wrong angle?

Having similar issues with kbhit() though I have found several articles
on different ways to emulate this in Linux, so I'll check that out.

Any ideas or how-to links for the output problem appreciated.

Thanks,
Greg


_______________________________________________
PLUG mailing list
PLUG at lists.pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug





More information about the PLUG mailing list