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?
Printable View
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().
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 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