next up previous contents
Next: getch Up: リファレンスマニュアル Previous: Func

  
fwrite

【目的】
fwrite - 行列をファイルにバイナリデータとして書き込む
【形式】
c = fwrite(fd, X, type)
   Integer c;
   Integer fd;
   Matrix X;
   String type;
【詳細】
fwrite(fd, mat, type) は行列の成分を指定したファイルに指定 したデータ型のバイナリで書き込む。データは行の順に書き込まれる。 fd は関数 fopen() が返すファイルディスクリプタ,X は書き込む行列, type は書き込むデータの型である。type には次に示す C 言語の データの型を文字列で指定する。
"char" : 文字 (8 bits)
"signed char" : 符合あり文字 (8 bits)
"unsigned char" : 符合なし文字 (8 bits)
"short" : 整数 (16 bits)
"signed short" : 符合あり整数 (16 bits)
"unsigned short" : 符合なし整数 (16 bits)
"int" : 整数 (16,32,64 bits)
"signed int" : 符合あり整数 (16,32,64 bits)
"unsigned int" : 符合なし整数 (16,32,64 bits)
"long" : 整数 (32 bits)
"signed long" : 符合あり整数 (32 bits)
"unsigned long" : 符合なし整数 (32 bits)
"float" : 単精度浮動小数点数 (32 bits)
"double" : 倍精度浮動小数点数 (32 bits)
【例題】
行列 A をint型のバイナリデータとして保存する
A = [1 2 3 4 5];
fd = fopen("data", "w");
fwrite(fd, A, "int");
fclose(fd);
【参照】
fopen(2.75), fclose(2.64), fscanf(2.82), fgets(2.69), fread(2.78)

next up previous contents
Next: getch Up: リファレンスマニュアル Previous: Func
Masanobu KOGA 平成11年10月2日