MFC 환경에서 콘솔(Console)에 디버깅 문자열을 출력(Output)하고자 한다면...
윈도우가 생성되기 전에 아래의 문장을 이용하여 먼저 콘솔을 생성해야 한다
#ifdef _DEBUG
if (!AllocConsole())
AfxMessageBox("Failed to create the console!", MB_ICONEXCLAMATION);
#endif
프로그램 중간에 디버깅 문자열을 콘솔에 출력하고자 하는 부분에 다음 코드를 이용한다
#ifdef _DEBUG
_cprintf("디버깅 문자열 %s\n", 문자열 포인터);
#endif
콘솔이 더이상 필요없을 경우에는 콘솔을 제거한다
#ifdef _DEBUG
if (!FreeConsole())
AfxMessageBox("Could not free the console!");
#endif
_cprintf() 함수는 printf()함수와 사용법이 동일하며 아래의 헤더파일이 필요함
#include <conio.h>