如何在运行程序后停止cmd关闭。 [英] How to stop cmd from closing after running the program.

查看:594
本文介绍了如何在运行程序后停止cmd关闭。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行编译然后运行。在我输入一些内容(要求输入2个数字以找出答案)后,我看不到最终结果。 cmd关闭了我。我听说过休息,系统暂停,但是还有其他任何方式吗?

I run compile then run. After I type some stuff in (asks to type in 2 numbers to find out the answers) I can''t see the end result. The cmd closes on me. I heard of break, system pause, but any other way of doing this?

推荐答案

使用getch()


或使用cin将使程序等待你的输入你可以看到结果
Use getch()

Or use cin which will make the program wait for your input and you can see the results


我是C ++的新手,我会把getch()
I''m sorta new to C++ where would I put getch()


声明变量x;

初始化它0


程序结束时说


coun<<" exit?"<< endl;

cin>> x;

if(x == 1)

退出(0);
Declare a variable x;
Initilize it 0

At the end of the program say

coun<<"exit ?"<<endl;
cin>>x;
if(x==1)
exit(0);


这篇关于如何在运行程序后停止cmd关闭。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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