how do I perform scanf twice in a while loop?

Started by draz, September 21, 2010, 10:23:43 AM

Previous topic - Next topic

draz

I have a scanf inside a while loop so that the user can put in input multiple times. I have a piece of code inside the loop to prevent an eternal loop. because of this, the program can only be used ten times before it quits. however, I want to replace that with a second scanf where the user can choose wheather or not to continue using the program. the problem is, that when I have a second scanf in the code, as soon as I press enter for the first scanf, it skips through the rest of the code and starts the loop over again, ignoring the second scanf. what is wrong?

Stefan Pendl

Enter or Return does send two characters, so you will have to filter that out.

I think there are examples posted, just search for scanf.
---
Stefan

Proud member of the UltraDefrag Development Team