可能重複:
How to stop C++ console application from exiting immediately?如何讓屏幕暫停?
這樣的IM學習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 */
這個問題以前曾問過這裏:http://stackoverflow.com/questions/2529617/how-to-stop-c-console-application-from-exiting-immediately(有幾種解決方案列在那裏)。 – 2010-04-27 23:26:14