I am new to programming and ran into an interesting problem. I wrote a simple program to try out using switch statements and at the end of the program I put cin.get(); to make the program wait for the user to press return. When I run the program, it'll do everything fine except it skips over cin.get();. I am using C++ 2008 Express Edition to write, compile and run my code. Here is my code.
Code:
#include <iostream>
using namespace std;
int main()
{
int num;
cout<<"Please pick a number from 1 to 3: ";
cin>> num;
switch ( num )
{
case 1:
cout<<"You are #1!\n";
break;
case 2:
cout<<"2 is the 2nd loneliest #...\n";
break;
case 3:
cout<<"3rd times a charm!\n";
break;
default:
cout<<"I did not understand you input.\n";
break;
}
cin.get();
}
Thanks for everyone's help! :-D