I have been learning C++ for a bit now, and i am noticing that cin.get(); seems to be unpredictable. Sometimes it works (that is it waits for input to continue), other times the program will just continue to input. I have heard it has to do with bad steams (like inputing letter for an integral value) but I made absolutely sure this was not happening and it did not help. I then was told about cin.good();. This did not seem to help. So what am I missing? is it a poor programming habit? Here is a simple example where cin.get does not do what I expect:
Code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int a;
cin>>a;
cout<<a<<endl;
cin.get();
return 0;
}