VC++ assert、OutputDebugString、GetLastError、TRACE 使用
#include <Windows.h>
#include <stdio.h>
#include <tchar.h>
#include <assert.h>
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
fopen("Danny.txt","r+");
int res = GetLastError();//VS工具菜单-错误查找中获取上一行代码的错误原因。
assert(res == 2);//可以输入条件表达式,但结果必须为真,为假则报错。
if(res == 2)
{
OutputDebugString(L"res == 2");//在调试模式下,输出窗口中显示括号内的字符串。
}
//if(res == 0)
//{
// TRACE(L"res的值为",res);//mfc环境在调试模式下,输出窗口中显示括号内的字符串。
//}
return 0;
}
浙公网安备 33010602011771号