What are the disadvantages of using uppercase 'W' in fopen compared to lowercase 'w'

6 ビュー (過去 30 日間)
Vince Vanhinsbergh
Vince Vanhinsbergh 2016 年 7 月 6 日
コメント済み: Star Strider 2016 年 7 月 6 日
fidx = fopen(filename,'Wb');
I know from the help file that the uppercase 'W' has something to do with buffering of outputs but I have yet to find any differences between files generated using uppercase 'W' compared to lowercase 'w'. It is obvious that the uppercase 'W' is much quicker than the lowercase 'w'.
Are there any downsides to using uppercase 'W' in simple binary file creation...?

回答 (1 件)

Jan Orwat
Jan Orwat 2016 年 7 月 6 日
編集済み: Jan Orwat 2016 年 7 月 6 日
I guess some memory is used for buffering purposes. There should not be any differences in written data. 'W' or 'A' are faster when writing small chunks of data repeatedly. When multiple read, write sequences called to the same file, buffer has to be flushed every iteration, so I guess this option may be slower in this scenario, but I have never tested it.
Read Loren Shure blog post and Yair Altman blog post about this topic.
  1 件のコメント
Star Strider
Star Strider 2016 年 7 月 6 日
I wasn’t aware that there was any significant difference. Thank you!
+1

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by