可能重复:
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;
}
一旦我运行程序,它接受输入,但退出在我能看看结果之前。我需要为程序做些什么才能退出,然后才能看看在结果?
您使用的是什么环境? – 2011-06-03 12:10:38
Qt创建者4.7。 – Gandalf 2011-06-03 12:15:01
您可以随时查看结果。只需捕获输出或从现有控制台运行即可。 – 2011-06-03 12:19:12