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

Started by
4 comments, last by GameDev.net 18 years, 10 months ago
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]
Advertisement
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.
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.
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
^^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.
That's cool.

This topic is closed to new replies.

Advertisement