C 教程
C 庫函數(shù) int ungetc(int char, FILE *stream) 把字符 char(一個無符號字符)推入到指定的流 stream 中,以便它是下一個被讀取到的字符。
下面是 ungetc() 函數(shù)的聲明。
int ungetc(int char, FILE *stream)
如果成功,則返回被推入的字符,否則返回 EOF,且流 stream 保持不變。
下面的實例演示了 ungetc() 函數(shù)的用法。
假設(shè)我們有一個文本文件 file.txt,它的內(nèi)容如下。文件將作為實例中的輸入:
this is json !c standard library !library functions and macros
讓我們編譯并運行上面的程序,這將產(chǎn)生以下結(jié)果:
this is json +c standard library +library functions and macros其他擴展