why do i need to put cin.get() twice?

Biorapture99 (9)
Hey guys, i was writing a very simple program and came a across an problem. In order to stop my program from closing i had to use cin.get () twice? Is this normal ? here is my code -

int main()
{
int a;
int b;
int sum;


cout << "To start this addition calculator, please enter a number!" << endl << endl;

cin >> a;

cout << "Now enter another number !" << endl << endl;

cin >> b;

sum = a + b;

cout << "The sum of those two numbers is " << sum << endl << endl;

cout << "This program was created by Omar Ismail" << endl <<endl;

cout << "Press enter to continue..." ;



cin.get ();
cin.get ();

return 0;
}
Last edited on
Registered users can post here. Sign in or register to post.