|
|||||||||||
|
Technical Support Support Resources
Product Information |
C51: CLEARING THE SCANF INPUT STREAMInformation in this article applies to:
QUESTIONI'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? ANSWERscanf 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
FORUM THREADSThe following Discussion Forum threads may provide information related to this topic.
Last Reviewed: Thursday, September 20, 2001 | ||||||||||
|
|||||||||||
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.