Sign in to follow this  

How to get console window to show up for output

This topic is 2336 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

You can create a console window by calling AllocConsole(). However, if you just want to log debug messages, consider using OutputDebugMessage() instead.

Share this post


Link to post
Share on other sites
[quote name='SiCrane' timestamp='1311559400' post='4839807']
You can create a console window by calling AllocConsole(). However, if you just want to log debug messages, consider using OutputDebugMessage() instead.
[/quote]

Thanks for the reply. But I am not able to do std::cout << "HELLO"; and see any output....using AllocConsole()

Share this post


Link to post
Share on other sites
[quote name='MARS_999' timestamp='1311568197' post='4839846']
[quote name='SiCrane' timestamp='1311559400' post='4839807']
You can create a console window by calling AllocConsole(). However, if you just want to log debug messages, consider using OutputDebugMessage() instead.
[/quote]

Thanks for the reply. But I am not able to do std::cout << "HELLO"; and see any output....using AllocConsole()
[/quote]


Your application automatically attaches the streams for std::cout and std::cin when the program is started.

The console created using AllocConsole() has its own streams associated with it after it was created.

If you want to, i[url="http://www.codeproject.com/KB/dialog/ConsoleAdapter.aspx?display=Print"]t is not difficult to attach the global cout and cin streams to the new console.[/url]

Share this post


Link to post
Share on other sites
I usually just leave my code alone and switch the subsystem to console rather than create it programmatically. Then when I no longer need the console, I just switch back to windows subsystem.

I haven't tried this in VC++ 2010, but I would guess it still works in the latest version...

Share this post


Link to post
Share on other sites

This topic is 2336 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.

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