feof
ファイル終端のテスト
説明
例
ファイルの終端まで読み取る
この badpoem.txt
ファイルから、一度に 1 行ずつファイルの終端まで読み取ります。
fopen
を使用してファイルを開きます。この関数は、ファイルの読み取りと書き込みに使用する一意のファイル識別子を割り当てます。
fid = fopen('badpoem.txt');
ファイルの終端に到達するまで、一度に 1 行ずつ読み取って表示します。
while ~feof(fid) tline = fgetl(fid); disp(tline) end
Oranges and lemons, Pineapples and tea. Orangutans and monkeys, Dragonflys or fleas.
ファイルを閉じます。
fclose(fid);
入力引数
ヒント
空のファイルを開いても、ファイルの終端指示子は設定されません。読み取り操作、および
fseek
、frewind
などその他の操作により、ファイル位置指定子が移動します。
拡張機能
C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。
スレッドベースの環境
MATLAB® の backgroundPool
を使用してバックグラウンドでコードを実行するか、Parallel Computing Toolbox™ の ThreadPool
を使用してコードを高速化します。
この関数はスレッドベースの環境を完全にサポートしています。詳細については、スレッドベースの環境での MATLAB 関数の実行を参照してください。
バージョン履歴
R2006a より前に導入R2022b: スレッドベースの環境での関数の使用
この関数はスレッドベースの環境をサポートしています。
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)