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 conflicting characters remain in the input stream

hello, there's a little problem with the scanf-function. My program

...
 scanf("%u",&A);
...
 
expects a unsigned integer. But when someone hits a unwanted character, scanf terminates. Any conflicting character remain in the input stream. How to clear the scanf-input-stream? Is there a known workaround for ARM7 ADuC7026)? In C51 you just
CLR ?C?charloaded
RET
But how on ARM7? Thanks for advice :-)

Parents
  • Hans,

    That's an over-interpretaion of that support note you found.
    Yes, it does have a buffer, which you can clear if you want to.
    But by no means does that imply it needs to be cleared

    I think maybe you misinterpreted my post. You need to clear it only (on the C51 scanf) if unwanted characters appear was my intended meaning. I thought that was clear from the context of the thread but maybe not. I certainly was not suggesting that it should be done as a matter-of-course. :)

Reply
  • Hans,

    That's an over-interpretaion of that support note you found.
    Yes, it does have a buffer, which you can clear if you want to.
    But by no means does that imply it needs to be cleared

    I think maybe you misinterpreted my post. You need to clear it only (on the C51 scanf) if unwanted characters appear was my intended meaning. I thought that was clear from the context of the thread but maybe not. I certainly was not suggesting that it should be done as a matter-of-course. :)

Children
No data