ジャンプ先: 概要. 戻り値. 関連項目. MEL 例.

概要

fread int int|float|string|vector

fread は 「元に戻す」が不可能「照会」が不可能「編集」が不可能 です。

次のバイト セットをバイナリ データとして読み取ります。データの型は仮引数によって解釈します。たとえば、整数の仮引数は fread に対し、読み取りを行い整数値を返すように指示します。 文字列は、NULL キャラクタが最初に現われるまで、またはファイルの最後まで読み取られます。文字列の読み取り制限は 1024 バイトです。 読み取られる文字列が 1024 バイトを超える場合、最初の 1024 バイトだけが返されます。fread コマンドによって返される型は、2 番目の引数の型に対応します。

戻り値

int 2 番目の引数が int の場合
float 2 番目の引数が float の場合
string 2 番目の引数が string の場合
vector 2 番目の引数が vector の場合

関連項目

fclose, feof, fflush, fgetline, fgetword, fopen, fprint, frewind, fwrite, pclose, popen

MEL 例

// Make a sample file to use as a test example
//
$exampleFileName = ( `internalVar -userTmpDir` + "example.tmp" );
$fileId=`fopen $exampleFileName "w"`;
fwrite $fileId "Hello there\n";
fclose $fileId;

// Now, open the file and read the data
//
$fileId=`fopen $exampleFileName "r"`;
string $s;
$s=`fread $fileId $s`;
print( $s + "\n" );
fclose $fileId;