MFC打开控制台的2种方式

方法一:
配置相关属性如下:
在这里插入图片描述

属性->配置属性->生成事件->后期生成事件->命令行 中添加
editbin /subsystem:console $(OutDir)$(TargetName).exe
使用cout或者printf向控制台输出 也可以通过获取标准输出句柄然后调用WriteConsole 方式输出

方法二:
在代码里面添加:

		AllocConsole();
		FILE *stream = nullptr;
		freopen_s(&stream, "CONOUT$", "w", stdout);

猜你喜欢

转载自blog.csdn.net/qq_23350817/article/details/106612504