...
Receiving input from a stream directly following an output to that stream without an intervening call to fflush()
, fseek()
, fsetpos()
, or rewind()
, or outputting to a stream after receiving input from it without a call to fseek()
, fsetpos()
, rewind()
if the file is not at end-of-file results in undefined behavior. Consequently, a call to one of these functions fseek()
, fflush()
or fsetpos()
is necessary between input and output to the same stream (see FIO07-A. Prefer fseek() to rewind()).
Non-Compliant Code Example
...