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

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

问题描述

我试过这个:

  main(){
int a;
cout<< 输入数字:;
cin>>一个;
cout<<一个;
cin.ignore(std :: numeric_limits< std :: streamsize> :: max(),'\\\
');
return 0;
}

但它不工作。



  system(

暂停);

你想要暂停的地方(在你的情况下, / p>

然而,由于许多安全问题,大多数会考虑使用 system 是不好的做法。请改用:

  cin.get(); 


I tried this:

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

But it didn't work.

解决方案

The easiest way is to simply place:

system("PAUSE");

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天全站免登陆