Using printf() in Windows programs

Started by
9 comments, last by tomdavis 20 years, 4 months ago
MV, it''s not clear what you''re asking.

If the program is supposed to run in the GUI subsystem - ie. the entry function is WinMain and the compiler/linker settings indicate GUI, then my AllocConsole etc. code will do the trick.

If the program is supposed to run in the Console subsystem - ie. the entry function is main and the compiler/linker settings indicate Console, there''s no need for AllocConsole etc. This includes Glut based programs as well as siaspete''s comment.

In fact, his suggestion is really the easiest. Change WinMain to main and use GetModuleHandle(NULL) to get the hInstance. Then use printf statements as you want. That the entry function is main rather than WinMain doesn''t mean you can''t register a class, create a window and enter into a message loop and so on.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

This topic is closed to new replies.

Advertisement