在win32应用中使用printf代码示例

本文提供了一个在Windows环境下32位应用程序中使用printf函数的示例,详细阐述了如何在win32应用中集成和调用printf进行输出。
摘要由CSDN通过智能技术生成

 

 
#include <windows.h>
#include <stdio.h>

/**
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, the 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.

Or you can use the code pattern as below to show messages on a console.
*/

int WINAPI WinMain(HIN
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值