// 在qt 中打开控制台窗口,首先include Window.h
#include <Windows.h>
// 在main函数中添加代码
AllocConsole();
freopen("CONOUT$", "w+t", stdout);
printf("hello world\n");
// 在MFC 中打开控制台
// 引用头文件io.h 和 fcntl.h
#include <io.h>
#include <fcntl.h>
// 在MFC窗口的OnInitDialog方法中调用
...
AllocConsole();
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
int hCrt = _open_osfhandle((long)handle, _O_TEXT);
FILE * hf = _fdopen(hCrt, "w");
*stdout = *hf;
printf("hello world\n");
...
Qt和MFC程序如何显示控制台窗口,显示printf信息
最新推荐文章于 2022-01-27 17:26:20 发布