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++ - 保持控制台窗口打开?
基础教程推荐
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- c++ STL设置差异 2022-01-01
