如何让屏幕暂停?

-1 c++ visual-c++ visual-c++-2010

可能重复:
如何阻止C++控制台应用程序立即退出?

所以即时学习c ++和我给出了这个例子,我想运行它.但我不能让它熬夜,除非我改变它.在我发布之后,如何让Microsoft Visual 2010在屏幕到达程序结束时保持屏幕状态?

#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 */
Run Code Online (Sandbox Code Playgroud)

Jam*_*lis 5

在Visual C++中,您可以:

  • 在断点处放置一个断点main并运行附加到调试器(Debug - > Start Debugging).当断点被击中时,您将能够查看控制台窗口.
  • 从调试器中分离运行(Debug - > Start Without Debugging).当应用程序终止时,控制台窗口将保持打开状态,并显示"按任意键继续..."提示.