トップページ > キーワード検索 > ungetc()
C言語規格
C言語(その他)
プログラム
その他
ungetc()
機能 入力ストリームへ文字を押し戻すことを表す。
定義 #include <stdio.h>

int ungetc ( int c, FILE * stream );
引数
c押し戻す文字(unsigned char型に変換される)
stream押し戻すストリーム(FILE)へのポインタ
戻り値 成功した場合は、変換されて押し戻された文字を返す。
エラーが発生した場合は、EOFを返す。
実装例
#include <stdio.h>

int main(void)
{
    int ret;
    int c;
    
    ret = ungetc('a', stdin);
    
    if (EOF != ret) {
        c = getchar();
        
        printf("c=%c\n", c);
    }
    
    return 0;
}
実行結果
c=a





inserted by FC2 system