There are several common issues with using cin and probably quite a few more that aren't common.
For example, if you don't need to handle bad input, then you can get away with always calling cin.ignore() after calls to cin >> to ignore the trailing newline.
If you do want to handle error conditions, then something like this usually works:Both those solutions allow mixing of cin >> and getline.Code:
// prompt here
while (!(cin >> data) || cin.get() != '\n')
// error message and re-prompt here
If you want it all encapsulated in some functions, see this post: