<分区>
我是 c++ 的新手,我想知道为什么我的 cin.get() 没有阻止 cmd 中的程序在完成后立即关闭?我在我以前的代码上尝试了 cin.get() 并且它有效,但由于某种原因它不适用于此代码。
#include <iostream>
int main()
{
using namespace std;
int carrots;
cout << "How many carrots do you have?" << endl;
cin >> carrots;
cout << "You have " << carrots << endl;
cin.get();
return 0;
}