Sign in to follow this  
SteveDeFacto

How to display text in the compiler output window?

Recommended Posts

I feel really stupid asking this since I have been programming for quite awhile but how do you display text in the compiler output window?

I always thought you just do this "std::cout << "Text to be displayed" << std::endl;" but when I do that nothing happens...

Share this post


Link to post
Share on other sites
As per diablos_blade's response, I have a wrapper that goes like this:


class DebugStream
{
private:
std::ostringstream o;

public:
~DebugStream(){ OutputDebugString(o.str().c_str()); }

template<class T> DebugStream &operator<<(const T &t){ o << t; return *this; }
};


which allows me to do things like:


void f()
{
int a=23;

DebugStream() << "a is equal to " << a << " at the moment\n";
}


Hope this is of use.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this