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++ - 保持控制台窗口打开?


基础教程推荐
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 常量变量在标题中不起作用 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01