tail head cat sleep
QR code linking to this page

manページ  — FREAD

名称

fread, fwrite – バイナリストリーム入出力

内容

ライブラリ

Standard C Library (libc, -lc)

書式

#include <stdio.h>

size_t
fread(void *ptr, size_t size, size_t nmemb, FILE *stream);

size_t
fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);

解説

fread() 関数は、 stream が指すストリームから、それぞれが size バイトの大きさのオブジェクトを nmemb 個読み込み、 ptr で指定された場所に保存します。

fwrite() 関数は、 ptr で指定された場所から、それぞれが size バイトの大きさのオブジェクトを nmembstream が指すストリームに書き込みます。

戻り値

fread() 関数と fwrite() 関数は、読み書きしたバイト数だけ ストリームのファイル位置インジケータを進め、 読み書きしたオブジェクト数を返します。 エラーが発生した場合、またはファイルの終了に達した場合は、 指定したものより少ないオブジェクト数 (または 0) を返します。

fread() 関数は、ファイルの終了とエラーを区別しません。 ファイルの終了かエラーかを判断するためには、呼び出し側が feof(3)ferror(3) を使用する必要があります。 fwrite() は、書き込みエラーが発生した場合に限って nmemb より少ない値を返します。

関連項目

read(2), write(2)

規格

fread() 関数と fwrite() 関数は、 ISO/IEC 9899:1990 ("ISO C90") に適合しています。

FREAD (3) March 8, 1994

tail head cat sleep
QR code linking to this page


このマニュアルページサービスについてのご意見は Ben Bullock にお知らせください。 Privacy policy.

Our grievance is not just against Unix itself, but against the cult of Unix zealots who defend and nurture it. They take the heat, disease, and pestilence as givens, and, as ancient shamans did, display their wounds, some self-inflicted, as proof of their power and wizardry. We aim, through bluntness and humor, to show them that they pray to a tin god, and that science, not religion, is the path to useful and friendly technology.
— The Unix Haters' handbook