Im trying to carry out input validation on a piece of code and have come across an issue.
Basically for the 1st input I used getline for the string and then for the 2nd input I use cin for the integer. I am aware you can convert the integer from a string with getline but I wish to use the validation underneath to cover for the fact that a user may enter a string instead of the required integer.
When this code runs the second revolution of the For Loop it fires out the first two requests without waiting for user input. I suspect its the clash with getline and cin but Im unsure how to resolve except for using getline which nullifies the validation code.
Any ideas?
If you need any more clarification on my long winded, tedious problem just ask.
You are screwing-up your gcount() by using ignore(). Get the count first, then ignore.
Hope this helps.
Yep you are spot on, cheers.
I was close to figuring it as I had placed cin.clear(); after the ignore and it started to work, wasnt sure why though and youve cleared (no pun intended) that up.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.