Feb 10, 2014 at 11:59am
My programme is working just fine but when I press enter after entering the game. It shows the last cout but closes imidiately. What to do?
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name = "";
int age = 0;
cout << "Enter your name.\n";
cin >> name;
cout << "Enter your age.\n";
cin >> age;
cout << "You name is:" << name << ".";
cout << "You age is:" << age << ".";
return 0;
}
Feb 10, 2014 at 12:02pm
Run the program from the command line, or change the settings in your IDE to avoid that the window close after the program has terminated.
Feb 10, 2014 at 4:17pm
add getch() just before return 0;
So it will wait for your enter to terminate.
Feb 11, 2014 at 10:37am
It worked. Thank you so much everyone.