We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
The C51 Library manual has the following note:<br> "This function is implementation-specific and is based on the operation of the _getkey and/or putchar functions."<br> <br> Presumably C166 is similar?<br> Have you checked the operation of your _getkey implementation.<br> <br> Have you reviewed this Thread:<br> <a href="">http://www.keil.com/forum/docs/thread1334.asp">http://www.keil.com/forum/docs/thread1334.asp</a>
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
Many thanks, thats it! I use ungetchar(0x0) and it works! Dietmar
Maybe it'd be easier to just read into a buffer, and then parse that - rather than trying to do it "on the fly?"