我学了一招,大家来共享:输出调试信息到Console?

bigjim 2000-07-28 02:29:00
加精
在InitInstance()中添加就能生成一个console.
#ifdef _DEBUG
if (!AllocConsole())
AfxMessageBox("Failed to create the console!", MB_ICONEXCLAMATION);
#endif
当然,必须在程序结束时进行收尾,在ExitInstance()中添加:
#ifdef _DEBUG
if (!FreeConsole())
AfxMessageBox("Could not free the console!");
#endif
在程序中需要输出调试信息的地方,可以运用这个调试窗口了:
_cprintf("Local value is %d\n", m_variable);
_cprintf的用法同printf一样。当然,要使用它,必须包含conio.h
#include <conio.h>
OK! That's all!





...全文
314 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
111 2001-06-23
  • 打赏
  • 举报
回复
xiexe
enigma 2001-01-11
  • 打赏
  • 举报
回复
hihi

1,649

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 非技术类
社区管理员
  • 非技术类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧