Another trick is to simply trap the enter key with another cin.get() like this:
[php]
#include <iostream>
using namespace std;
int main()
{
int age;
cout << "enter age\n";
cin >> age;
if (age <= 18)
cout << "child\n";
cin.get(); // trap enter
cin.get(); // wait
return 0;
}
[/php]
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
Offline 5,792 posts
since Oct 2004