MFC程序输出调试信息到控制台

    技术2022-05-19  19

    在程序开始处添加:

    #ifdef _DEBUG if ( !AllocConsole() ) AfxMessageBox( _T("Failed to create the console!"), MB_ICONEXCLAMATION ); #endif

     

    在需要输出调试信息的地方添加:

    #include <conio.h> #ifdef _DEBUG _cprintf("xxxxxxxxxxx"); #endif

     

    在程序结束处添加:

    #ifdef _DEBUG if ( !FreeConsole() ) AfxMessageBox( _T("Could not free the console!") ); #endif


    最新回复(0)