I am using the following code:
#include using namespace std; int main(int argc, char **argv) { string lineInput = \" \"; while(line
When cin fails to extract, it doesn't change the target variable. So whatever string your program last read successfully is stuck in lineInput.
cin
lineInput
You need to check cin.fail(), and Erik has shown the preferred way to do that.
cin.fail()