MFC 调用 printf 输出

 如下代码即可:


#include <io.h>
#include <fcntl.h> 

void OpenConsole()
{
	AllocConsole();
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	int hCrt = _open_osfhandle((long)handle,_O_TEXT);
	FILE * hf = _fdopen( hCrt, "w" );
	*stdout = *hf;
}
BOOL CHappyMFCApp::InitInstance()
{
	OpenConsole();
	printf("asdf");
......
}



posted @ 2014-12-25 15:26  SuperThinker  阅读(1)  评论(0编辑  收藏  举报  来源