Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.2 - 日本語

Change language to:
English - Français - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilabヘルプ >> Files : Input/Output functions > mput

mput

指定したバイナリ形式でバイトまたはワードを書き込む

呼び出し手順

mput(x [, type, fd])

引数

x

浮動小数点数または整数型の数値のベクトル

fd

スカラー: mopen関数により返された ファイル記述子. -1は,直近にオープンされたファイルを意味します. デフォルト値は-1です.

type

文字列: xの全エントリを書き込む際に 使用されるバイナリ形式を指定.

説明

mput 関数は, ストリームパラメータfdで指定した出力先にデータを を書き込みます. データはポインタのカレントの位置に書き込まれ, ポインタのインジケータは前に適当に前に移動されます.

typeパラメータは変換指定子で, 以下のフラグ文字(デフォルト値 "l") のどれかを指定します:

"l", "i", "s", "ul", "ui", "us", "d", "f", "c", "uc"

それぞれ long long, int (long int), short, unsigned long long int, unsigned int (long int), unsigned short, double, float, char, unsigned char を書き込みます. 書き込んだバイトは,(リトルインディアンモードで)マシンに 依存するバイナリファイルを出力するために (リトルインディアンステータスを確認することにより) 必要に応じて自動的にスワップされます. このデフォルトのスワップモードは,mopen関数に フラグswap = 0を追加することにより抑制できます.

"..l" または "..b"

"l"または"b"文字を type指定子の末尾に追加することにより, リトルインディアンまたはビッグインディアンモードで書き込むことも可能です. 例えば,"db"はビッグインディアンモードでdoubleを書き込みます.

filen = 'test.bin';
mopen(filen,'wb');
mput(1996,'l');mput(1996,'i');mput(1996,'s');mput(98,'c');
// force little-endian
mput(1996,'ll');mput(1996,'il');mput(1996,'sl');mput(98,'cl');
// force big-endian
mput(1996,'lb');mput(1996,'ib');mput(1996,'sb');mput(98,'cb');
mclose();
mopen(filen,'rb');
if 1996<>mget(1,'l') then pause,end
if 1996<>mget(1,'i') then pause,end
if 1996<>mget(1,'s') then pause,end
if   98<>mget(1,'c') then pause,end
// リトルインディアンを強制
if 1996<>mget(1,'ll') then pause,end
if 1996<>mget(1,'il') then pause,end
if 1996<>mget(1,'sl') then pause,end
if   98<>mget(1,'cl') then pause,end
// ビッグインディアンを強制
if 1996<>mget(1,'lb') then pause,end
if 1996<>mget(1,'ib') then pause,end
if 1996<>mget(1,'sb') then pause,end
if   98<>mget(1,'cb') then pause,end
mclose();

参照

  • mclose — オープンされているファイルを閉じる
  • meof — ファイルの終端に達したかどうかを確認する
  • mfprintf — 変換,整形し,ファイルにデータを書き込む
  • fprintfMat — 行列をファイルに書き込む
  • mfscanf — 標準入力から入力を読み込む (C言語の scanf 関数へのインターフェイス)
  • fscanfMat — テキストファイルから行列を読み込む
  • mget — 指定したバイナリ形式で バイトまたはワードを読み込み, double に変換
  • mgetl — アスキーファイルから行を読み込む
  • mgetstr — ファイルから文字列を読み込む
  • mopen — ファイルをオープン
  • mprintf — 変換, 整形し, Scilab主ウインドウにデータを書き込む
  • mputl — テキストファイルに文字列を書き込む
  • mputstr — ファイルに文字列を書き込む
  • mscanf
  • mseek — バイナリファイルの中でカレントの位置を設定する.
  • mtell — ファイル先頭基準でカレントバイトのオフセットを返す
  • mdelete — ファイルを削除
Report an issue
<< movefile Files : Input/Output functions mputl >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Feb 14 15:02:14 CET 2019