Visual C++ Enable Console(Visual C++ 启用控制台)
问题描述
我在 Visual C++ 中创建了一个空项目,但现在我需要控制台来显示调试输出.
I created an Empty Project in Visual C++, but now I need the Console to display debug output.
如何在不重新创建项目或在 VS 输出窗口中显示输出的情况下启用控制台?
How can I enable the Console without recreating the project or show the output in the VS output window?
推荐答案
你可以随时调用AllocConsole 在代码中为您的应用程序创建一个控制台,并将其附加到进程.FreeConsole 将删除控制台,将进程从它也是.
You can always call AllocConsole in code to create a console for your application, and attach it to the process. FreeConsole will remove the console, detaching the process from it, as well.
如果您希望所有标准输出流数据都进入控制台,您还需要使用 SetStdHandle 来适当地重定向输出.这是一个页面显示完成这个完整过程的工作代码,包括分配控制台并重定向输出.
If you want all standard output stream data to go to the console, you need to also use SetStdHandle to redirect the output appropriately. Here is a page showing working code to do this full process, including allocating the console and redirecting the output.
这篇关于Visual C++ 启用控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Visual C++ 启用控制台


- 近似搜索的工作原理 2021-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 静态初始化顺序失败 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- 从python回调到c++的选项 2022-11-16
- 如何对自定义类的向量使用std::find()? 2022-11-07
- C++ 协变模板 2021-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01