Sign in to follow this  
MARS_999

How to get console window to show up for output

Recommended Posts

SiCrane    11839
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
MARS_999    1627
[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
frob    44904
[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
Nypyren    12063
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

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