【发布时间】:2011-09-07 18:53:13
【问题描述】:
可能重复:
How to stop C++ console application from exiting immediately?
我有以下控制台程序:
#include <iostream>
using namespace std;
int main()
{
int a;
int b;
cout<<"Enter a";
cin>>a;
cout<<"Enter b";
cin>>b;
int result = a*b;
cout<<"You entered"<<a<<"and you entered"<<b<<"Their product is"<<result<<endl;
return 0;
}
一旦我运行程序,它会接受输入但在我查看结果之前退出。我需要做什么才能让程序在我查看结果之前不退出?。
【问题讨论】:
-
你使用的是什么环境?
-
您可以随时查看结果。只需捕获输出或从现有控制台或其他东西运行它。
标签: c++