I'm sure there is a better/easier way but the following will give you a buffer of 0 so it will output everything immediatly.
The MyStreamBuf class was taken and trimed from
http://cboard.cprogramming.com/showt...398#post377398
Code:
#include <iostream>
#include <cstdio>
class MyStreamBuf : public std::streambuf {
public:
MyStreamBuf(FILE *outFile)
: o(outFile)
{
setg(buf, buf+1, buf+1);
}
protected:
virtual int overflow (int c = EOF)
{
return fputc(c, o);
}
private:
FILE *o;
char buf[1];
};
int main()
{
MyStreamBuf buff(stdout);
cout.rdbuf(&buff);
cout<<"Hello World\n";
}