Jump to content
  • Advertisement
Sign in to follow this  
Taram

How to get cout to work in windows? (solved)

This topic is 4723 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 am trying to use cout for some debugging info but nothing prints out to dos window when I run program from there. Do I need to link any special libraries to get this to work? [Edited by - Taram on June 20, 2005 11:48:35 PM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
I believe cout only works when your app was compiled as a console app? It won't work if the app was created by a Win32 app.

Share this post


Link to post
Share on other sites
I can still run a win32 app if I compile it as console app, correct? Maybe it is just a matter of creating a dummy console app and seeing what is linked in. Worth a shot I guess.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
There is a shorcut wherein you could still write your app but compile it as a console app so that both windows will appear and still be able to use cout. I should warn you though that this is not typically how it is done. Typically, you would write your app as a Win32 app and use console functions to allocate, write text to, and deallocate a console window.

You'd call AllocConsole() to allocate the console window, WriteConsole() to write text, and FreeConsole() to destroy it.

Check here, for more details on managing a console window via a windowed app:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/character_mode_applications.asp

Share this post


Link to post
Share on other sites
^^Nice info. I got the console mode to work finally. Not sure if I want to use the info in your link because I am trying to keep my code as cross-platform as possible. It only works in win32 right now but I try to keep the "windows only" functions to a minimum in case I decide to port my code to linux in the future.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
That's cool.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!