#include <stdio.h>
int fgetc(FILE *stream);
int getchar(void);
char *fgets(int size;
char s[restrict size], int size, FILE *restrict stream);
int ungetc(int c, FILE *stream);
getchar() is equivalent to fgetc(stdin).
fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A terminating null byte ('\0') is stored after the last character in the buffer.
ungetc() は、後の read 操作で読めるように、 c を unsigned char にキャストして stream に書き戻す。 書き戻された文字は逆順に戻される; 書き戻しとして保証されているのは、一文字だけである。
ここで述べた関数や stdio ライブラリの入力関数を同じ入力ストリームに対して互いに混ぜて使うことができる。
これらの処理を停止せずに行いたいときは、 unlocked_stdio(3) を参照のこと。
fgets() は、成功すると s を返し、エラーや 1 文字も読み込んでいないのにファイルの終わりになった 場合に NULL を返す。
ungetc() は成功すると c を返し、エラーの場合は EOF を返す。
| インターフェース | 属性 | 値 |
| fgetc(), fgets(), getchar(), ungetc() | Thread safety | MT-Safe |