OSDN Git Service

5b4999adc13de227e6adcd400e94f5daf8bc82ba
[linuxjm/LDP_man-pages.git] / draft / man3 / stdio.3
1 .\" Copyright (c) 1990, 1991 Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)stdio.3     6.5 (Berkeley) 5/6/91
33 .\"
34 .\" Converted for Linux, Mon Nov 29 16:07:22 1993, faith@cs.unc.edu
35 .\" Modified, 2001-12-26, aeb
36 .\"
37 .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi
38 .\"       all rights reserved.
39 .\" Translated Mon Jan 20 23:06:18 JST 1997
40 .\"       by YOSHINO Takashi <yoshino@civil.jcn.nihon-u.ac.jp>
41 .\" Updated & Modified Thu Feb 14 21:39:49 JST 2002
42 .\"       by Yuichi SATO <ysato@h4.dion.ne.jp>
43 .\" Updated & Modified Sun Sep  7 14:36:19 JST 2003
44 .\"       by Yuichi SATO <ysato444@yahoo.co.jp>
45 .\" Updated & Modified Sat Jan 17 03:18:29 JST 2004 by Yuichi SATO
46 .\"
47 .\"WORD: position indicator   位置指示子
48 .\"WORD: positioning requests 位置指定リクエスト
49 .\"
50 .TH STDIO 3  2001-12-26 "" "Linux Programmer's Manual"
51 .\"O .SH NAME
52 .SH 名前
53 .\"O stdio \- standard input/output library functions
54 stdio \- 標準入出力ライブラリ関数
55 .\"O .SH SYNOPSIS
56 .SH 書式
57 .B #include <stdio.h>
58 .sp
59 .BI "FILE *" stdin ;
60 .br
61 .BI "FILE *" stdout ;
62 .br
63 .BI "FILE *" stderr ;
64 .\"O .SH DESCRIPTION
65 .SH 説明
66 .\"O The standard I/O library provides a simple and efficient buffered stream
67 .\"O I/O interface.
68 標準入出力ライブラリは、簡単かつ効果のよい、
69 バッファリングされたストリーム入出力インターフェースを提供する。
70 .\"O Input and output is mapped into logical data streams and the
71 .\"O physical I/O characteristics are concealed.
72 入力と出力は論理データストリームに割り付けられ、
73 入出力の物理的な特徴は隠蔽される。
74 .\"O The functions and macros are
75 .\"O listed below; more information is available from the individual man pages.
76 このライブラリに属する関数とマクロを以下に挙げる。
77 より詳しい情報は個々の man ページから得ることができる。
78 .PP
79 .\"O A stream is associated with an external file (which may be a physical
80 .\"O device) by
81 .\"O .I opening
82 .\"O a file, which may involve creating a new file.
83 .\"O Creating an existing file
84 .\"O causes its former contents to be discarded.
85 ファイルを
86 .I オープン (open) する
87 ことによって、
88 ストリームは外部ファイル (通常は物理デバイス) に連結される。
89 この操作には新しくファイルを作成することも含まれる。
90 既存のファイルと同じ名前のファイルを新たに作ると、
91 もとのファイルの中身が捨てられてしまう。
92 .\"O If a file can support
93 .\"O positioning requests (such as a disk file, as opposed to a terminal) then a
94 .\"O .I file position indicator
95 .\"O associated with the stream is positioned at the start of the file (byte
96 .\"O zero), unless the file is opened with append mode.
97 ファイルが位置指定リクエストをサポートしている
98 (ディスクファイルなどが相当する。逆の例としては端末が挙げられる) 場合、
99 そのストリームに連結された
100 .I ファイル位置指示子 (file position indicator)
101 は、追加モードで開かれない限りファイルの先頭 (0 バイト目) に位置する。
102 .\"O If append mode is used,
103 .\"O it is unspecified whether the position indicator will be placed at the
104 .\"O start or the end of the file.
105 追加モードを使用した場合、
106 位置指示子をファイルの先頭に置かれるか末尾に置かれるかは規定されていない。
107 .\"O The position indicator is maintained by
108 .\"O subsequent reads, writes and positioning requests.
109 位置指示子は、
110 以降の読み書きや位置指定リクエストによって変更される。
111 .\"O All input occurs
112 .\"O as if the characters were read by successive calls to the
113 .\"O .BR fgetc (3)
114 .\"O function; all output takes place as if all characters were written by
115 .\"O successive calls to the
116 .\"O .BR fputc (3)
117 .\"O function.
118 すべての入力は、
119 .BR fgetc (3)
120 関数を次々に呼び出して文字を読み込んだかのように行われる。
121 一方すべての出力は、
122 .BR fputc (3)
123 関数を次々に呼び出して文字を書き込んだかのように行われる。
124 .PP
125 .\"O A file is disassociated from a stream by
126 .\"O .I closing
127 .\"O the file.
128 ファイルを
129 .I クローズ (close) する
130 ことによって、そのファイルはストリームから切り離される。
131 .\"O Output streams are flushed (any unwritten buffer contents are
132 .\"O transferred to the host environment) before the stream is disassociated from
133 .\"O the file.
134 出力ストリームは、そのストリームがファイルから切り離される前にフラッシュされる
135 (書き込まれていないすべてのバッファの内容がホスト環境に転送される)。
136 .\"O The value of a pointer to a
137 .\"O .I FILE
138 .\"O object is indeterminate after a file is closed (garbage).
139 .I FILE
140 オブジェクトへのポインタの値は、
141 ファイルを閉じた後では不確定になる (ゴミになってしまう)。
142 .PP
143 .\"O A file may be subsequently reopened, by the same or another program
144 .\"O execution, and its contents reclaimed or modified (if it can be
145 .\"O repositioned at the start).
146 ファイルはその後 (同じまたは別のプログラムによって)
147 再びオープンされることもあり、
148 その内容が修正されたり変更されたりする
149 (そのファイルで先頭への位置移動が可能であれば)。
150 .\"O If the main function returns to its original caller, or the
151 .\"O .BR exit (3)
152 .\"O function is called, all open files are closed
153 .\"O (hence all output streams are
154 .\"O flushed) before program termination.
155 main 関数がもとの呼び出し側に返ったり、
156 .BR exit (3)
157 関数が呼ばれた場合、
158 プログラムの終了の前に
159 現在開いているすべてのファイルは閉じられる
160 (その結果、すべての出力ストリームはフラッシュされる)。
161 .\"O Other methods of program termination,
162 .\"O such as
163 .\"O .BR abort (3)
164 .\"O do not bother about closing files properly.
165 プログラムの停止に
166 .BR abort (3)
167 のような他の方法を用いた場合には、
168 ファイルが正しく閉じられる保証はない。
169 .PP
170 .\"O At program startup, three text streams are predefined and need not be
171 .\"O opened explicitly:
172 .\"O .I standard input
173 .\"O (for reading conventional input),
174 .\"O .I standard output
175 .\"O (for writing conventional input), and
176 .\"O .I standard error
177 .\"O (for writing diagnostic output).
178 プログラムの起動時に 3 個のテキストストリームが予め定義されており、
179 それらは明示的に開く必要がない。
180 .I 標準入力 (standard input)
181 (通常の入力を読み取るのに使う)、
182 .I 標準出力 (standard output)
183 (通常の出力を書き込むのに使う)、
184 .I 標準エラー出力 (standard error)
185 (診断出力を書き込むのに使う) である。
186 .\"O These streams are abbreviated
187 .\"O .IR stdin , stdout
188 .\"O and
189 .\"O .IR stderr .
190 これらのストリームは
191 .IR stdin ,
192 .IR stdout ,
193 .I stderr
194 と短縮して表現される。
195 .\"O When opened, the standard error stream is not fully buffered; the standard
196 .\"O input and output streams are fully buffered if and only if the streams do
197 .\"O not to refer to an interactive device.
198 オープンされたときには、
199 標準エラーストリームは
200 完全にはバッファリングされていない。
201 標準入力ストリームと標準出力ストリームは、
202 ストリームがインタラクティブなデバイスを参照していなければ、
203 完全にバッファリングされている。
204 .PP
205 .\"O Output streams that refer to terminal devices are always line buffered by
206 .\"O default; pending output to such streams is written automatically whenever
207 .\"O an input stream that refers to a terminal device is read.
208 端末デバイスを参照する出力ストリームは、
209 デフォルトでは常に行単位でバッファリングされている。
210 ただしそのようなストリームにおけるバッファ内の出力は、
211 端末デバイスを参照している入力ストリームからの読み込みがあるたびに、
212 自動的に書き込まれる。
213 .\"O In cases where a
214 .\"O large amount of computation is done after printing part of a line on an
215 .\"O output terminal, it is necessary to
216 .\"O .BR fflush (3)
217 .\"O the standard output before going off and computing so that the output will
218 .\"O appear.
219 出力端末に行の一部を書き込んだ後で大量の計算を行う場合、
220 出力が表示されるように、計算に取りかかる前に標準出力に対して
221 .BR fflush (3)
222 を実行する必要がある。
223 .PP
224 .\"O The
225 .\"O .I stdio
226 .\"O library is a part of the library
227 .\"O .B libc
228 .\"O and routines are automatically loaded as needed by the compilers
229 .\"O .BR cc (1)
230 .\"O and
231 .\"O .BR pc (1).
232 .I stdio
233 ライブラリは
234 .B libc
235 ライブラリの一部であり、ルーチンは
236 コンパイラー
237 .BR cc (1)
238
239 .BR pc (1)
240 によって必要な時に自動的に読み込まれる。
241 .\"O The
242 .\"O SYNOPSIS
243 .\"O sections of the following manual pages indicate which include files are to
244 .\"O be used, what the compiler declaration for the function looks like and
245 .\"O which external variables are of interest.
246 後述する man ページ中の「書式」の節には、
247 どのインクルードファイルを使用しなければならないか、
248 その関数のコンパイラー宣言はどのようなものか、
249 どのような外部変数が関係するのかが示されている。
250 .PP
251 .\"O The following are defined as macros; these names may not be reused without
252 .\"O first removing their current definitions with
253 .\"O .BR #undef :
254 .BR BUFSIZ ,
255 .BR EOF ,
256 .BR FILENAME_MAX ,
257 .BR FOPEN_MAX ,
258 .BR L_cuserid ,
259 .BR L_ctermid ,
260 .BR L_tmpnam ,
261 .BR NULL ,
262 .BR SEEK_END ,
263 .BR SEEK_SET ,
264 .BR SEEK_CUR ,
265 .BR TMP_MAX ,
266 .BR clearerr ,
267 .BR feof ,
268 .BR ferror ,
269 .BR fileno ,
270 .\" Not on Linux: .BR fropen ,
271 .\" Not on Linux: .BR fwopen ,
272 .BR getc ,
273 .BR getchar ,
274 .BR putc ,
275 .BR putchar ,
276 .BR stderr ,
277 .BR stdin ,
278 .\"O .BR stdout .
279 .B stdout
280 はマクロとして定義されている。
281 これらの名前は、現在の定義を
282 .B #undef
283 で削除しない限り、再利用することはできない。
284 .\"O Function versions of the macro functions
285 マクロ関数の関数版として、
286 .BR feof ,
287 .BR ferror ,
288 .BR clearerr ,
289 .BR fileno ,
290 .BR getc ,
291 .BR getchar ,
292 .BR putc ,
293 .B putchar
294 .\"O exist and will be used if the macros definitions are explicitly removed.
295 がある。
296 マクロの定義が明示的に消去されている場合には、
297 これらを使用することになるだろう。
298 .\"O .SS "List of Functions"
299 .SS 関数のリスト
300 .TS
301 ;
302 lb lb
303 lb l.
304 .\"O Function   Description
305 関数  説明
306 _
307 .\"O clearerr   check and reset stream status
308 .\"O fclose     close a stream
309 .\"O fdopen     stream open functions
310 .\"O feof       check and reset stream status
311 .\"O ferror     check and reset stream status
312 .\"O fflush     flush a stream
313 clearerr        ストリームの状態の確認とリセット
314 fclose  ストリームをクローズする
315 fdopen  ストリームをオープンする
316 feof    ストリームの状態の確認とリセット
317 ferror  ストリームの状態の確認とリセット
318 fflush  ストリームをフラッシュする
319 .\"O fgetc      get next character or word from input stream
320 .\"O fgetpos    reposition a stream
321 .\"O fgets      get a line from a stream
322 .\"O fileno     return the integer descriptor of the argument stream
323 .\"O fopen      stream open functions
324 .\"O fprintf    formatted output conversion
325 .\"O fpurge     flush a stream
326 .\"O fputc      output a character or word to a stream
327 .\"O fputs      output a line to a stream
328 .\"O fread      binary stream input/output
329 .\"O freopen    stream open functions
330 fgetc   次の文字または語を入力ストリームから獲得する
331 fgetpos ストリームの位置を取得する
332 .\"nakano ↑原文違うのでは?
333 fgets   ストリームから行を取得する
334 fileno  引き数であるストリームの整数値のディスクリプタを返す
335 fopen   ストリームをオープンする
336 fprintf 書式付き出力変換
337 fpurge  ストリームをフラッシュする
338 fputc   文字または語をストリームに出力する
339 fputs   行をストリームに出力する
340 fread   バイナリーストリーム入出力
341 freopen ストリームをオープンする
342 .\"O fscanf     input format conversion
343 .\"O fseek      reposition a stream
344 .\"O fsetpos    reposition a stream
345 .\"O ftell      reposition a stream
346 .\"O fwrite     binary stream input/output
347 .\"O getc       get next character or word from input stream
348 .\"O getchar    get next character or word from input stream
349 .\"O gets       get a line from a stream
350 .\"O getw       get next character or word from input stream
351 fscanf  書式付き入力変換
352 fseek   ストリームの位置指示子を移動する
353 fsetpos ストリームの位置指示子を移動する
354 ftell   ストリームの位置を取得する
355 .\"nakano ↑これも。
356 fwrite  バイナリーストリーム入出力
357 getc    次の文字または語を入力ストリームから取得する
358 getchar 次の文字または語を入力ストリームから取得する
359 gets    行を入力ストリームから取得する
360 getw    次の文字または語を入力ストリームから取得する
361 .\"O mktemp     make temporary filename (unique)
362 .\"O perror     system error messages
363 .\"O printf     formatted output conversion
364 .\"O putc       output a character or word to a stream
365 .\"O putchar    output a character or word to a stream
366 .\"O puts       output a line to a stream
367 .\"O putw       output a character or word to a stream
368 .\"O remove     remove directory entry
369 .\"O rewind     reposition a stream
370 .\"O scanf      input format conversion
371 mktemp  他と重ならないテンポラリファイル名を作る
372 perror  システムエラーメッセージ
373 printf  書式付き出力変換
374 putc    文字または語をストリームに出力する
375 putchar 文字または語をストリームに出力する
376 puts    行をストリームに出力する
377 putw    文字または語をストリームに出力する
378 remove  ディレクトリエントリを削除する
379 rewind  ストリームの位置指示子を移動する
380 scanf   書式付き入力変換
381 .\"O setbuf     stream buffering operations
382 .\"O setbuffer  stream buffering operations
383 .\"O setlinebuf stream buffering operations
384 .\"O setvbuf    stream buffering operations
385 .\"O sprintf    formatted output conversion
386 .\"O sscanf     input format conversion
387 .\"O strerror   system error messages
388 .\"O sys_errlist        system error messages
389 .\"O sys_nerr   system error messages
390 .\"O tempnam    temporary file routines
391 .\"O tmpfile    temporary file routines
392 .\"O tmpnam     temporary file routines
393 .\"O ungetc     un-get character from input stream
394 setbuf  ストリームのバッファリングの操作
395 setbuffer       ストリームのバッファリングの操作
396 setlinebuf      ストリームのバッファリングの操作
397 setvbuf ストリームのバッファリングの操作
398 sprintf 書式付き出力変換
399 sscanf  書式付き入力変換
400 strerror        システムエラーメッセージ
401 sys_errlist     システムエラーメッセージ
402 sys_nerr        システムエラーメッセージ
403 tempnam テンポラリファイルの操作
404 tmpfile テンポラリファイルの操作
405 tmpnam  テンポラリファイルの操作
406 ungetc  入力ストリームへ 1 文字戻す。
407 .\"O vfprintf   formatted output conversion
408 .\"O vfscanf    input format conversion
409 .\"O vprintf    formatted output conversion
410 .\"O vscanf     input format conversion
411 .\"O vsprintf   formatted output conversion
412 .\"O vsscanf    input format conversion
413 vfprintf        書式付き出力変換
414 vfscanf 書式付き入力変換
415 vprintf 書式付き出力変換
416 vscanf  書式付き入力変換
417 vsprintf        書式付き出力変換
418 vsscanf 書式付き入力変換
419 .TE
420 .\"O .SH "CONFORMING TO"
421 .SH 準拠
422 .\"O The
423 .\"O .I stdio
424 .\"O library conforms to C89.
425 .I stdio
426 ライブラリは C89 に準拠している。
427 .\"O .SH "SEE ALSO"
428 .SH 関連項目
429 .BR close (2),
430 .BR open (2),
431 .BR read (2),
432 .BR write (2),
433 .BR stdout (3),
434 .BR unlocked_stdio (3)