.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de) .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" Modified Wed Jul 28 11:12:07 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Fri Sep 8 15:48:13 1995 by Andries Brouwer (aeb@cwi.nl) .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH FGETC 3 2013\-12\-31 GNU "Linux Programmer's Manual" .SH 名前 fgetc, fgets, getc, getchar, ungetc \- 文字と文字列の入力 .SH 書式 .nf \fB#include \fP .sp \fBint fgetc(FILE *\fP\fIstream\fP\fB);\fP \fBchar *fgets(char *\fP\fIs\fP\fB, int \fP\fIsize\fP\fB, FILE *\fP\fIstream\fP\fB);\fP \fBint getc(FILE *\fP\fIstream\fP\fB);\fP \fBint getchar(void);\fP \fBint ungetc(int \fP\fIc\fP\fB, FILE *\fP\fIstream\fP\fB);\fP .fi .SH 説明 \fBfgetc\fP() は、 \fIstream\fP から次の文字を \fIunsigned char\fP として読み、 \fIint\fP にキャストして返す。ファイルの終わりやエラーとなった場合は \fBEOF\fP を返す。 .PP \fBgetc\fP() は \fBfgetc\fP() と同様だが、 \fIstream\fP を複数回評価するマクロとして実装されているかもしれない。 .PP \fBgetchar\fP() は \fBgetc(\fP\fIstdin\fP\fB)\fP と同じである。 .PP \fBfgets\fP() は \fIstream\fP から最大で \fIsize\fP \- 1 個の文字を読み込み、 \fIs\fP が指すバッファーに格納する。読み込みは \fBEOF\fP または改行文字を読み込んだ後で停止する。 読み込まれた改行文字はバッファーに格納される。 終端のヌルバイト (\(aq\e0\(aq) が一つバッファーの中の最後の文字の後に書き込まれる。 .PP \fBungetc\fP() は、後の read 操作で読めるように、 \fIc\fP を \fIunsigned char\fP にキャストして \fIstream\fP に書き戻す。 書き戻された文字は逆順に戻される; 書き戻しとして保証されているのは、一文字だけである。 .PP ここで述べた関数や \fIstdio\fP ライブラリの入力関数を同じ入力ストリームに対して互いに混ぜて使うことができる。 .PP これらの処理を停止せずに行いたいときは、 \fBunlocked_stdio\fP(3) を参照のこと。 .SH 返り値 \fBfgetc\fP(), \fBgetc\fP(), \fBgetchar\fP() は、文字を \fIunsigned char\fP として読んで \fIint\fP にキャストして返す。ファイルの終わりやエラーの場合は \fBEOF\fP を返す。 .PP \fBfgets\fP() は、成功すると \fIs\fP を返し、エラーや 1 文字も読み込んでいないのにファイルの終わりになった 場合に NULL を返す。 .PP \fBungetc\fP() は成功すると \fIc\fP を返し、エラーの場合は \fBEOF\fP を返す。 .SH 準拠 C89, C99, POSIX.1\-2001. 入力ストリームのファイルディスクリプターに対して、 \fIstdio\fP ライブラリの入力関数と、低レベル呼び出しの \fBread\fP(2) を混ぜて呼び出す事は勧められない。 結果がどうなるかは分からず、おそらくあなたの 望んでいる結果にはならないだろう。 .SH 関連項目 \fBread\fP(2), \fBwrite\fP(2), \fBferror\fP(3), \fBfgetwc\fP(3), \fBfgetws\fP(3), \fBfopen\fP(3), \fBfread\fP(3), \fBfseek\fP(3), \fBgetline\fP(3), \fBgets\fP(3), \fBgetwchar\fP(3), \fBputs\fP(3), \fBscanf\fP(3), \fBungetwc\fP(3), \fBunlocked_stdio\fP(3), \fBfeature_test_macros\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。