Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

disable cout buffering

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

Thank you!
0
Comment
Question by:paulchen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
md041797 earned 100 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

688 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