且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从C中的eof恢复标准输入

更新时间:2023-11-17 23:22:16

使用 ungetc()推回一个字符可以清除流的EOF指示器。

Using ungetc() to push back a character can clear the EOF indicator for a stream.


C99§7.19 .7.11 ungetc 函数

 int ungetc(int c, FILE *stream);

成功调用 ungetc 函数清除流的文件结束指示符。读取或丢弃所有推回的字符后,流的文件位置指示符的值应与推回字符之前的值相同。 。

A successful call to the ungetc function clears the end-of-file indicator for the stream. The value of the file position indicator for the stream after reading or discarding all pushed-back characters shall be the same as it was before the characters were pushed back.