如何让屏幕暂停? [英] How do i get the screen to pause?
本文介绍了如何让屏幕暂停?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
如何阻止C ++控制台应用程序立即退出?
所以我学习c ++和i给了这个例子,我想运行它。但我不能让它留下来,除非我改变它。在发布程序结束后,我如何获得Microsoft visual 2010以保持屏幕显示?
#include< iostream>
using namespace std;
int area(int length,int width); / *函数声明* /
/ *主程序:* /
int main()
{
int this_length,this_width;
cout<< 输入长度:; / *< --- line 9 * /
cin>> this_length;
cout<< 输入宽度:;
cin>> this_width;
cout<< \\\
; / *< --- line 13 * /
cout<< < this_length< x< this_width;
cout<< rectangle is< area(this_length,this_width);
return 0;
}
/ *主程序结束* /
/ *计算区域的函数:* /
int area(int length,int width)/ * start的函数定义* /
{
int number;
number = length * width;
return number;
} / *函数结束定义* /
/ *函数结束* /
在Visual C ++中,您可以:
- 在断点处放置一个断点
main
并运行附加到调试器(Debug - > Start Debugging)。 - 从调试器运行分离(Debug - > Start Without Debugging)。当应用程序终止时,控制台窗口将保持打开,并按按任意键继续...提示。
Possible Duplicate:
How to stop C++ console application from exiting immediately?
So im learning c++ and i was given this example and i wanted to run it. But i cannot get it to stay up, unless i change it. How do i get Microsoft visual 2010 to keep up the screen when it gets to the end of the program after I release it?
#include<iostream>
using namespace std;
int area(int length, int width); /* function declaration */
/* MAIN PROGRAM: */
int main()
{
int this_length, this_width;
cout << "Enter the length: "; /* <--- line 9 */
cin >> this_length;
cout << "Enter the width: ";
cin >> this_width;
cout << "\n"; /* <--- line 13 */
cout << "The area of a " << this_length << "x" << this_width;
cout << " rectangle is " << area(this_length, this_width);
return 0;
}
/* END OF MAIN PROGRAM */
/* FUNCTION TO CALCULATE AREA: */
int area(int length, int width) /* start of function definition */
{
int number;
number = length * width;
return number;
} /* end of function definition */
/* END OF FUNCTION */
解决方案
In Visual C++ you can either:
- Put a breakpoint at the closing brace of
main
and run attached to the debugger (Debug -> Start Debugging). When the breakpoint is hit you will be able to view the console window. - Run detached from the debugger (Debug -> Start Without Debugging). When the application terminates, the console window will stay open with a "Press any key to continue..." prompt.
这篇关于如何让屏幕暂停?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文