win32/vc 程序调试信息命令行输出

来源:互联网 发布:韩国网络手游下载平台 编辑:程序博客网 时间:2024/05/07 15:43

如果程序在调试时,输出窗口看不到了怎么办,那就让调试信息显示在命令行窗口

在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!   

0 0
原创粉丝点击