Link to home
Start Free TrialLog in
Avatar of List244
List244

asked on

Force Buffer Usage cout

Hi, how can I set my cout statements to a forced buffer?
In other words, how can I stop it from drawing until flushed?
Avatar of jkr
jkr
Flag of Germany image

I'd write to a stringstream and push that one to 'cout' when needed, e.g. like

#include <iostream>
#include <sstream>
using namespace std;

//...

stringstream ss;

ss << "Some text " << endl << "Some integer value " << 42 << " floating point " << 3.141 << endl;
// ... more

// and finally:

cout << ss.str();
BTW, an 'ostringstream' might be suitable even better, e.g.

ostringstream oss;

oss << "Some text " << endl << "Some integer value " << 42 << " floating point " << 3.141 << endl;
// ... more

// and finally:

cout << oss.str();
Avatar of List244
List244

ASKER

The problem with that is my values are not normal.  I am using colored values which draw to the screen
and pretty much what I would like to do is clear out a little of the blinking when redrawing.
That should work even for control characters. By 'buffering' the output, you'll write that when your done with all the formatting and the output, so you should get rid of the problem that way.
Avatar of List244

ASKER

My output has so many colors though, it would almost be the same.  Because I would have to buffer a single character and
then print.  My actual draw routine does not give too much flicker, my problem is when I clear and redraw.  My main problem
is I would like this clear function(self-written not system("cls")) not to register until it has been redrawn.

I could modify the clear function not to clear those areas in which will be drawn to pretty easily, but I was just curious if I could just
stop output until I was ready instead.
>>Because I would have to buffer a single character and then print.

How are you doing the 'color thing' exactly at the moment?
Avatar of List244

ASKER

I am using SetConsoleTextAttribute, then I am printing out the character.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Make "to activate that one to complete the flicker and blinking completely" read "to activate that one to eliminate the flicker and blinking completely" *grmpf* ;o)
Avatar of List244

ASKER

Haha, I knew what you meant, just give me a little while so I can actually try it out and see how it works.
I should be able to get to it tomorrow.
Take you time, I just re-read it and simply didn't like it *g*