如何保持打开控制台? [英] How do I keep open the console?

查看:129
本文介绍了如何保持打开控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过这样:

main() {
    int a;
    cout << "Enter a number: ";
    cin >> a;
    cout << a;
    cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    return 0;
}

但它没有工作。

推荐答案

最简单的方法是简单地的地方:

The easiest way is to simply place:

system("PAUSE");

无论你想暂停是(在你的情况下,在上述行返回0;)

wherever you want the pause to be (in your case, in the line above return 0;)

然而,由于大量的安全问题,大多数人会考虑使用系统的是不好的做法。相反,尝试使用:

However due to lots of security issues, most would consider the use of system to be bad practice. Instead, try using:

cin.get();

这篇关于如何保持打开控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆