我下面的基本C++代碼不起作用。當我在Visual Studio Express中運行它時,它會在輸入第二個數字後關閉命令提示符。提前致謝。Visual Studio命令提示符關閉儘管我試圖用cin.get()停止它()
#include <iostream>
using namespace std;
int main()
{
int num1, num2, answer;
cout << " Enter a number: ";
cin >> num1;
answer = num1 * num1;
cout << " the sum of the number is: " << answer << endl;
cout << "Enter a 2nd number";
cin >> num2;
answer = answer + num2;
cout << "The sum of the two numbers is: " << answer << endl;
cin.get();
return 0;
}
嘗試在第一次輸入之後放置一個cin.get()。 – robbannn 2014-10-04 08:31:09