Hello
... It is not taking the inputs of name and address as it should. Got confused how to solve it.
After the operator>>()
, the input is left pointing at the end-of-line character. At the next call of get()
, there is already input available (the end-of-line character), so it reads up to the end-of-line delimiter, which is zero characters.
A solution is to discard the rest of the line after you read the values, using cin.ignore()
-- check the manual for how to use it.
cout << "Enter customer id:";
cin >> x->id;
cin.ignore(999, '\n');
Also, instead of <iostream.h>
, you should be using <iostream>
. iostream.h
is an old version that is only kept for backwards compatibility with very old code.