Hi, I'm writing this simple program, and for some reason if I don't use a cin.ignore at the end of the getInput function, the next time the function is called it skips the first entry. I understand why this may happen after the first getline, but here I'm using two getline's, then some cin's then calling the function again. Can someone explain what is happening with the buffer here?
Your first input operation reads until a newline character, and consumes the newline. Your last input operation, without the ignore, reads until whitespace but does not consume it. This means that the next time around, that whitespace is still there.
I personally recommend always reading entire lines of user input at a time and then parsing the line with a std::istringtream if you need to extract individual tokens (e.g. multiple numbers per line).