This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

scanf does not waint for input

hello,

I'm using the scanf function and it works as expected.
But, if there a termination, eg. because of a conflict with the input stream, the next scanf call does not wait for the a input.
The return value (EOF) is ok.

Have everyone a hint for me?

Dietmar

Parents
  • I think the thing is that when scanf can't interpret a character it puts it back in the stream and returns with an error. The next call to scanf will get the character from the stream which caused an error last time. So between the two calls you have to check what there is in the stream with putchar and maybe put it back with ungetchar.
    - Mike

Reply
  • I think the thing is that when scanf can't interpret a character it puts it back in the stream and returns with an error. The next call to scanf will get the character from the stream which caused an error last time. So between the two calls you have to check what there is in the stream with putchar and maybe put it back with ungetchar.
    - Mike

Children