在程序开始处添加: #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