I just put cin.get(); into my code and it isnt working so I tried to check this by putting in system ("PAUSE") and it works fine with that...any reasons why it doesnt work?
I just put cin.get(); into my code and it isnt working so I tried to check this by putting in system ("PAUSE") and it works fine with that...any reasons why it doesnt work?
Without any code to look at I will need to use my crystal ball to divine you an answer... Do you have any previous cin >> statements in your code before the point in which you attempt to call cin.get()? If so, then that's your answer. Add a second cin.get() call along with the first, either that or add a cin.ignore() call before the first cin.get().
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
That is probably it...so ashould I jsut use cin.ignore after ever cin>> statement? Just incase I use cin.get();?
Or not use cin >> at all.
Read everything into a buffer using getline, then parse the line using say a string stream.
It's the same problem a C programmers face with mixing scanf() with say fgets(), then resorting to brain damage like fflush(stdin)
Mixing input styles in either language generally leads to problems of one sort or another. IMO, it's best to separate the task of input from conversion.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
If you don't want to bother with remembering the intricacies of cin input and would rather focus on other programming challenges, consider using this:
http://cboard.cprogramming.com/showp...728#post503728