Someone must know whats happening to my loop


Hey Guys, I have posted once before on this subject but I'm still having problems with this damn loop!!

When the program loops around again for some reason it keeps saying "That team is not registered please try again" when I never entered a name!! and then straight after it lets me enter a name again!!

Any suggestions would be most appreciated
Last edited on
didn't you just post this exact same question in another thread here?

http://www.cplusplus.com/forum/beginner/12929/

Someone even replied to it, then you responded by deleting your post and reposting it. If you don't understand the answer, that's fine, but if that's the case, then say so. Don't repost the same problem several times.

anyway like jsmith said in that other thread, the problem is related to you using cin >> an_integer_variable;, as this does not remove the trailing newline character.

The solution is to get input some other way (getline()), or to purge the newline character. I don't really know much about console stuff, but to my knowledge you can use sync() to wipe the input buffer. So try calling cin.sync(); after every cin >> an_integer_variable;.
yes I did post this earlier today and I also posted saying I was unsure as to what jsmith meant but No one replied so I just thought perhaps i could repost and people will look at the thread again.

I do apologise about what I did though.

And thank you Disch I shall look in to the ways you have suggested, I only remove my code from this site purely because a few students from my Uni are doing the same assignment and this site is well known meaning I don't want them stealing my code or using snippets of it. Hope you understand. thanks
Topic archived. No new replies allowed.