Working, Studying, 잡다구리보관소/IT, Science
MFC에서 콘솔창 사용하기
장안동베짱e
2011. 5. 27. 00:20
//헤더 인클루드
#include <io.h>
#include <fcntl.h>
//콘솔창 allocation 콘솔창이 필요 하면 _CONSOLE을 define한다.
#ifdef _CONSOLE
int hCrt;
FILE *hf;
FreeConsole();
AllocConsole();
hCrt = _open_osfhandle( (long) GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT );
hf = _fdopen( hCrt, "w" );
*stdout = *hf;
setvbuf( stdout, NULL, _IONBF, 0 );
#endif
이렇게 하면 콘솔창이 뜨고 printf로 디버깅을 할 수 있다.
#include <io.h>
#include <fcntl.h>
//콘솔창 allocation 콘솔창이 필요 하면 _CONSOLE을 define한다.
#ifdef _CONSOLE
int hCrt;
FILE *hf;
FreeConsole();
AllocConsole();
hCrt = _open_osfhandle( (long) GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT );
hf = _fdopen( hCrt, "w" );
*stdout = *hf;
setvbuf( stdout, NULL, _IONBF, 0 );
#endif
이렇게 하면 콘솔창이 뜨고 printf로 디버깅을 할 수 있다.
아 오랜만에 윈도우 프로그램 코딩 하려니 가물가물 하네요.