C++ - Hold the console window open?(C++ - 保持控制台窗口打开?)
问题描述
我的问题非常简单,但我正在从 C# 过渡到 C++,我想知道在 C++ 中打开控制台窗口的命令是什么?
My question is super simple, but I'm transitioning from C# to C++, and I was wondering what command holds the console window open in C++?
我知道在C#中,最基本的方式是:
I know in C#, the most basic way is:
Console.ReadLine();
或者如果你想让用户按任意键,它:
Or if you want to let the user press any key, its:
Console.ReadKey(true);
你如何在 C++ 中做到这一点?我在这里问这个简单的问题的唯一原因是我无法在互联网上找到一个好的和明确的答案.
How do you do this in C++? The only reason I ask this simple of a question here, is that I haven't been able to find a good and clear answer out there on the internet.
推荐答案
std::cin.get();
怎么样?
此外,如果您使用的是 Visual Studio,则无需调试即可运行(默认为 CTRL-F5),并且最终不会关闭控制台.如果你在调试的情况下运行它,你总是可以在 main()
的右大括号处放置一个断点.
Also, if you're using Visual Studio, you can run without debugging (CTRL-F5 by default) and it won't close the console at the end. If you run it with debugging, you could always put a breakpoint at the closing brace of main()
.
这篇关于C++ - 保持控制台窗口打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++ - 保持控制台窗口打开?


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