I'm not sure I understand your question. Scanf doesn't write, it reads. Once you have read a character with scanf, you cannot put it back into the stream in any portable way. If you are using buffered input and if you understand how your particular implementation works, you can write your own functions to peep at the next character before taking it, or to put the last character taken back into the buffer.

Generally speaking, this is how C input works: The operating system collects and manipulates keyboard input and places the characters into an OS buffer. This is not a buffer manipulable by the programmer.

When the programmer calls an input function, the language makes a blocking call for input using a low-level read. This call does not return until an end of line or end of file is found. When that condition is detected, the collected characters are put into the C input stream. If the stream is not buffered, some data may be lost. It depends on how the programmer uses the various input functions.

Functions that are not provided by the language may be written by the programmer. This act requires a knowledge of the platform and OS in use. For instance, one may do just about anything by writing functions that use the Win Console API. Similarly, but not the same, for Unix variants.