|ARM Technical Support Knowledge Articles|
Applies to: General Topics
Information in this article applies to:
I'm using scanf to read formatted input from the serial port. If there is no data ready, I want to exit this routine. How do I do this?
The scanf routine is designed to read input until a character is input that conflicts with the format string. When such a character is read, then and only then does scanf return. So, if there is no input available, scanf just waits.
Since scanf does not terminate if no characters are available, you must write your own functions to read and process your input stream. The best place to start is to look at the source code for getkey and putchar. The files getkey.c and putchar.c may be found in the lib directory of your compiler installation.
Article last edited on: 2004-11-15 16:55:07
Did you find this article helpful? Yes No
How can we improve this article?