.\" Copyright (c) 1990, 1991 Regents of the University of California. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)stdio.3 6.5 (Berkeley) 5/6/91 .\" .\" Converted for Linux, Mon Nov 29 16:07:22 1993, faith@cs.unc.edu .\" Modified, 2001-12-26, aeb .\" .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi .\" all rights reserved. .\" Translated Mon Jan 20 23:06:18 JST 1997 .\" by YOSHINO Takashi .\" Updated & Modified Thu Feb 14 21:39:49 JST 2002 .\" by Yuichi SATO .\" Updated & Modified Sun Sep 7 14:36:19 JST 2003 .\" by Yuichi SATO .\" Updated & Modified Sat Jan 17 03:18:29 JST 2004 by Yuichi SATO .\" .\"WORD: position indicator 位置指示子 .\"WORD: positioning requests 位置指定リクエスト .\" .TH STDIO 3 2001-12-26 "" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O stdio \- standard input/output library functions stdio \- 標準入出力ライブラリ関数 .\"O .SH SYNOPSIS .SH 書式 .B #include .sp .BI "FILE *" stdin ; .br .BI "FILE *" stdout ; .br .BI "FILE *" stderr ; .\"O .SH DESCRIPTION .SH 説明 .\"O The standard I/O library provides a simple and efficient buffered stream .\"O I/O interface. 標準入出力ライブラリは、簡単かつ効果のよい、 バッファリングされたストリーム入出力インターフェースを提供する。 .\"O Input and output is mapped into logical data streams and the .\"O physical I/O characteristics are concealed. 入力と出力は論理データストリームに割り付けられ、 入出力の物理的な特徴は隠蔽される。 .\"O The functions and macros are .\"O listed below; more information is available from the individual man pages. このライブラリに属する関数とマクロを以下に挙げる。 より詳しい情報は個々の man ページから得ることができる。 .PP .\"O A stream is associated with an external file (which may be a physical .\"O device) by .\"O .I opening .\"O a file, which may involve creating a new file. .\"O Creating an existing file .\"O causes its former contents to be discarded. ファイルを .I オープン (open) する ことによって、 ストリームは外部ファイル (通常は物理デバイス) に連結される。 この操作には新しくファイルを作成することも含まれる。 既存のファイルと同じ名前のファイルを新たに作ると、 もとのファイルの中身が捨てられてしまう。 .\"O If a file can support .\"O positioning requests (such as a disk file, as opposed to a terminal) then a .\"O .I file position indicator .\"O associated with the stream is positioned at the start of the file (byte .\"O zero), unless the file is opened with append mode. ファイルが位置指定リクエストをサポートしている (ディスクファイルなどが相当する。逆の例としては端末が挙げられる) 場合、 そのストリームに連結された .I ファイル位置指示子 (file position indicator) は、追加モードで開かれない限りファイルの先頭 (0 バイト目) に位置する。 .\"O If append mode is used, .\"O it is unspecified whether the position indicator will be placed at the .\"O start or the end of the file. 追加モードを使用した場合、 位置指示子をファイルの先頭に置かれるか末尾に置かれるかは規定されていない。 .\"O The position indicator is maintained by .\"O subsequent reads, writes and positioning requests. 位置指示子は、 以降の読み書きや位置指定リクエストによって変更される。 .\"O All input occurs .\"O as if the characters were read by successive calls to the .\"O .BR fgetc (3) .\"O function; all output takes place as if all characters were written by .\"O successive calls to the .\"O .BR fputc (3) .\"O function. すべての入力は、 .BR fgetc (3) 関数を次々に呼び出して文字を読み込んだかのように行われる。 一方すべての出力は、 .BR fputc (3) 関数を次々に呼び出して文字を書き込んだかのように行われる。 .PP .\"O A file is disassociated from a stream by .\"O .I closing .\"O the file. ファイルを .I クローズ (close) する ことによって、そのファイルはストリームから切り離される。 .\"O Output streams are flushed (any unwritten buffer contents are .\"O transferred to the host environment) before the stream is disassociated from .\"O the file. 出力ストリームは、そのストリームがファイルから切り離される前にフラッシュされる (書き込まれていないすべてのバッファの内容がホスト環境に転送される)。 .\"O The value of a pointer to a .\"O .I FILE .\"O object is indeterminate after a file is closed (garbage). .I FILE オブジェクトへのポインタの値は、 ファイルを閉じた後では不確定になる (ゴミになってしまう)。 .PP .\"O A file may be subsequently reopened, by the same or another program .\"O execution, and its contents reclaimed or modified (if it can be .\"O repositioned at the start). ファイルはその後 (同じまたは別のプログラムによって) 再びオープンされることもあり、 その内容が修正されたり変更されたりする (そのファイルで先頭への位置移動が可能であれば)。 .\"O If the main function returns to its original caller, or the .\"O .BR exit (3) .\"O function is called, all open files are closed .\"O (hence all output streams are .\"O flushed) before program termination. main 関数がもとの呼び出し側に返ったり、 .BR exit (3) 関数が呼ばれた場合、 プログラムの終了の前に 現在開いているすべてのファイルは閉じられる (その結果、すべての出力ストリームはフラッシュされる)。 .\"O Other methods of program termination, .\"O such as .\"O .BR abort (3) .\"O do not bother about closing files properly. プログラムの停止に .BR abort (3) のような他の方法を用いた場合には、 ファイルが正しく閉じられる保証はない。 .PP .\"O At program startup, three text streams are predefined and need not be .\"O opened explicitly \(em .\"O .I standard input .\"O (for reading conventional input), \(em .\"O .I standard output .\"O (for writing conventional input), and .\"O .I standard error .\"O (for writing diagnostic output). プログラムの起動時に 3 個のテキストストリームが予め定義されており、 それらは明示的に開く必要がない。 \(em .I 標準入力 (standard input) (通常の入力を読み取るのに使う)、\(em .I 標準出力 (standard output) (通常の出力を書き込むのに使う)、 .I 標準エラー出力 (standard error) (診断出力を書き込むのに使う) である。 .\"O These streams are abbreviated .\"O .IR stdin , stdout .\"O and .\"O .IR stderr . これらのストリームは .IR stdin , .IR stdout , .I stderr と短縮して表現される。 .\"O When opened, the standard error stream is not fully buffered; the standard .\"O input and output streams are fully buffered if and only if the streams do .\"O not to refer to an interactive device. オープンされたときには、 標準エラーストリームは 完全にはバッファリングされていない。 標準入力ストリームと標準出力ストリームは、 ストリームがインタラクティブなデバイスを参照していなければ、 完全にバッファリングされている。 .PP .\"O Output streams that refer to terminal devices are always line buffered by .\"O default; pending output to such streams is written automatically whenever .\"O an input stream that refers to a terminal device is read. 端末デバイスを参照する出力ストリームは、 デフォルトでは常に行単位でバッファリングされている。 ただしそのようなストリームにおけるバッファ内の出力は、 端末デバイスを参照している入力ストリームからの読み込みがあるたびに、 自動的に書き込まれる。 .\"O In cases where a .\"O large amount of computation is done after printing part of a line on an .\"O output terminal, it is necessary to .\"O .BR fflush (3) .\"O the standard output before going off and computing so that the output will .\"O appear. 出力端末に行の一部を書き込んだ後で大量の計算を行う場合、 出力が表示されるように、計算に取りかかる前に標準出力に対して .BR fflush (3) を実行する必要がある。 .PP .\"O The .\"O .I stdio .\"O library is a part of the library .\"O .B libc .\"O and routines are automatically loaded as needed by the compilers .\"O .BR cc (1) .\"O and .\"O .BR pc (1). .I stdio ライブラリは .B libc ライブラリの一部であり、ルーチンは コンパイラー .BR cc (1) と .BR pc (1) によって必要な時に自動的に読み込まれる。 .\"O The .\"O SYNOPSIS .\"O sections of the following manual pages indicate which include files are to .\"O be used, what the compiler declaration for the function looks like and .\"O which external variables are of interest. 後述する man ページ中の「書式」の節には、 どのインクルードファイルを使用しなければならないか、 その関数のコンパイラー宣言はどのようなものか、 どのような外部変数が関係するのかが示されている。 .PP .\"O The following are defined as macros; these names may not be reused without .\"O first removing their current definitions with .\"O .BR #undef : .BR BUFSIZ , .BR EOF , .BR FILENAME_MAX , .BR FOPEN_MAX , .BR L_cuserid , .BR L_ctermid , .BR L_tmpnam , .BR NULL , .BR SEEK_END , .BR SEEK_SET , .BR SEEK_CUR , .BR TMP_MAX , .BR clearerr , .BR feof , .BR ferror , .BR fileno , .\" Not on Linux: .BR fropen , .\" Not on Linux: .BR fwopen , .BR getc , .BR getchar , .BR putc , .BR putchar , .BR stderr , .BR stdin , .\"O .BR stdout . .B stdout はマクロとして定義されている。 これらの名前は、現在の定義を .B #undef で削除しない限り、再利用することはできない。 .\"O Function versions of the macro functions マクロ関数の関数版として、 .BR feof , .BR ferror , .BR clearerr , .BR fileno , .BR getc , .BR getchar , .BR putc , .B putchar .\"O exist and will be used if the macros definitions are explicitly removed. がある。 マクロの定義が明示的に消去されている場合には、 これらを使用することになるだろう。 .\"O .SS "List of Functions" .SS 関数のリスト .TS ; lb lb lb l. .\"O Function Description 関数 説明 _ .\"O clearerr check and reset stream status .\"O fclose close a stream .\"O fdopen stream open functions .\"O feof check and reset stream status .\"O ferror check and reset stream status .\"O fflush flush a stream clearerr ストリームの状態の確認とリセット fclose ストリームをクローズする fdopen ストリームをオープンする feof ストリームの状態の確認とリセット ferror ストリームの状態の確認とリセット fflush ストリームをフラッシュする .\"O fgetc get next character or word from input stream .\"O fgetpos reposition a stream .\"O fgets get a line from a stream .\"O fileno return the integer descriptor of the argument stream .\"O fopen stream open functions .\"O fprintf formatted output conversion .\"O fpurge flush a stream .\"O fputc output a character or word to a stream .\"O fputs output a line to a stream .\"O fread binary stream input/output .\"O freopen stream open functions fgetc 次の文字または語を入力ストリームから獲得する fgetpos ストリームの位置を取得する .\"nakano ↑原文違うのでは? fgets ストリームから行を取得する fileno 引き数であるストリームの整数値のディスクリプタを返す fopen ストリームをオープンする fprintf 書式付き出力変換 fpurge ストリームをフラッシュする fputc 文字または語をストリームに出力する fputs 行をストリームに出力する fread バイナリーストリーム入出力 freopen ストリームをオープンする .\"O fscanf input format conversion .\"O fseek reposition a stream .\"O fsetpos reposition a stream .\"O ftell reposition a stream .\"O fwrite binary stream input/output .\"O getc get next character or word from input stream .\"O getchar get next character or word from input stream .\"O gets get a line from a stream .\"O getw get next character or word from input stream fscanf 書式付き入力変換 fseek ストリームの位置指示子を移動する fsetpos ストリームの位置指示子を移動する ftell ストリームの位置を取得する .\"nakano ↑これも。 fwrite バイナリーストリーム入出力 getc 次の文字または語を入力ストリームから取得する getchar 次の文字または語を入力ストリームから取得する gets 行を入力ストリームから取得する getw 次の文字または語を入力ストリームから取得する .\"O mktemp make temporary filename (unique) .\"O perror system error messages .\"O printf formatted output conversion .\"O putc output a character or word to a stream .\"O putchar output a character or word to a stream .\"O puts output a line to a stream .\"O putw output a character or word to a stream .\"O remove remove directory entry .\"O rewind reposition a stream .\"O scanf input format conversion mktemp 他と重ならないテンポラリファイル名を作る perror システムエラーメッセージ printf 書式付き出力変換 putc 文字または語をストリームに出力する putchar 文字または語をストリームに出力する puts 行をストリームに出力する putw 文字または語をストリームに出力する remove ディレクトリエントリを削除する rewind ストリームの位置指示子を移動する scanf 書式付き入力変換 .\"O setbuf stream buffering operations .\"O setbuffer stream buffering operations .\"O setlinebuf stream buffering operations .\"O setvbuf stream buffering operations .\"O sprintf formatted output conversion .\"O sscanf input format conversion .\"O strerror system error messages .\"O sys_errlist system error messages .\"O sys_nerr system error messages .\"O tempnam temporary file routines .\"O tmpfile temporary file routines .\"O tmpnam temporary file routines .\"O ungetc un-get character from input stream setbuf ストリームのバッファリングの操作 setbuffer ストリームのバッファリングの操作 setlinebuf ストリームのバッファリングの操作 setvbuf ストリームのバッファリングの操作 sprintf 書式付き出力変換 sscanf 書式付き入力変換 strerror システムエラーメッセージ sys_errlist システムエラーメッセージ sys_nerr システムエラーメッセージ tempnam テンポラリファイルの操作 tmpfile テンポラリファイルの操作 tmpnam テンポラリファイルの操作 ungetc 入力ストリームへ 1 文字戻す。 .\"O vfprintf formatted output conversion .\"O vfscanf input format conversion .\"O vprintf formatted output conversion .\"O vscanf input format conversion .\"O vsprintf formatted output conversion .\"O vsscanf input format conversion vfprintf 書式付き出力変換 vfscanf 書式付き入力変換 vprintf 書式付き出力変換 vscanf 書式付き入力変換 vsprintf 書式付き出力変換 vsscanf 書式付き入力変換 .TE .\"O .SH "CONFORMING TO" .SH 準拠 .\"O The .\"O .I stdio .\"O library conforms to C89. .I stdio ライブラリは C89 に準拠している。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR close (2), .BR open (2), .BR read (2), .BR write (2), .BR stdout (3), .BR unlocked_stdio (3)