• Advertisement
Sign in to follow this  

How to display text in the compiler output window?

This topic is 2594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement