Solved

disable cout buffering

Posted on 1997-06-10
4
1,143 Views
Last Modified: 2012-06-27
How can I disable the buffering of output from cout?

Thank you!
0
Comment
Question by:paulchen
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
md041797 earned 50 total points
ID: 1163881
use:

cout.setf (ios::unitbuf, 0);

This forces a buffer of 1 char, which is actually no buffer at all.


0
 

Author Comment

by:paulchen
ID: 1163882
hello md!

thank you for your answer.
unfortunately, it didn't work. it still gets all buffered and
output after program termination.

0
 
LVL 4

Expert Comment

by:md041797
ID: 1163883
I've never seen this before.  What platform/compiler?

BTW, I recall that cout is unitbuf by default.
0
 
LVL 2

Expert Comment

by:sprinkmeier
ID: 1163884
Does "cerr" behave like you want it to (ie. unbuffered?) If it does not, then the problem could be with the OS, not the libraries you are using. (cerr is tied to fd 2 (stderr) instead of fd 1 (stdout) and is supposed to be unbuffered, though both are based the same parent class (as far as I know, may be implementation dependant)).

"clog" is supposed to be an unbuffered "cerr".
How do they do it? (tracking this doen might help)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now