Article View: gnu.gcc.help
Article #50956How do you turn buffering off with cout?
From: Peter K. Campbell
Date: Thu, 15 Jul 1993 04:02
Date: Thu, 15 Jul 1993 04:02
24 lines
1781 bytes
1781 bytes
I've been trying to turn the buffering off on cout, so I can do things like read records & print out messages to that effect immediately, rather than having to wait for several messages to be sent before appearing. Being a bit of a novice at C++, I naturally assumed that seeing as you can do a setbuf with stdout in C, there should be some sort of equivalent command you can use with cout, but I haven't found anything yet. So far, the only way I can manage to turn off the buffering on cout is to do a: setbuf(stdout,0); which seems to be against the spirit of C++, as it turns off buffering on cout as a side effect. Is there anyway of making some kind of call to cout to get the same effect? I thought that cout.rdbuf->setbuf(0,0); would do it, but it has no effect. I've tried a few other things, like cout.sync_with_stdio(); and these had the expected effect (i.e. nothing). So, does anyone know of a way to turn cout buffering off with a call actually mentioning cout? Peter K. Campbell p.campbell@trl.oz.au
Technical Details
Message-ID:
<1993Jul15.040210.6518@trl.oz.au>Path:
arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!gatech!swrinde!cs.utexas.edu!uunet!munnari.oz.au!bruce.cs.monash.edu.au!trlluna!titan!gort!peterShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,dfacf8e4c1b7d405,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1993-07-15 01:13:12 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!gatech!swrinde!cs.utexas.edu!uunet!munnari.oz.au!bruce.cs.monash.edu.au!trlluna!titan!gort!peter From: peter@gort.trl.OZ.AU (Peter K. Campbell) Subject: How do you turn buffering off with cout? Message-ID: <1993Jul15.040210.6518@trl.oz.au> Summary: Can't turn buffering off cout Keywords: cout, buffer, stdout Sender: root@trl.oz.au (System PRIVILEGED Account) Organization: Telecom Research Labs, Melbourne, Australia Date: Thu, 15 Jul 1993 04:02:10 GMT Lines: 24