|ARM Technical Support Knowledge Articles|
Applies to: C51 C Compiler
Information in this article applies to:
I'm using the scanf function and it works as expected, but sometimes it does not wait for a key to be pressed before returning. It seems that there are characters from previous scanf commands in the I/O stream. Is there a function I can call to clear the input buffer before I call scanf?
scanf has an input buffer that holds previous characters from the I/O stream. Use the following small assembler function to clear this input buffer.
; CLR_CHAR.A51 EXTRN BIT (?C?charloaded) PUBLIC clear_getchar ?PR?clear_getchar SEGMENT CODE RSEG ?PR?clear_getchar clear_getchar: CLR ?C?charloaded RET END
Article last edited on: 2001-09-20 00:00:00
Did you find this article helpful? Yes No
How can we improve this article?