fwrite() - effect of size and count on performance

前端 未结 3 1522
忘了有多久
忘了有多久 2020-12-18 18:59

There seems to be a lot of confusion regarding the purpose of the two arguments \'size\' and \'count\' in fwrite(). I am trying to figure out which will be faster -

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-18 19:22

    The purpose of two arguments gets more clear, if you consider ther return value, which is the count of objects successfuly written/read to/from the stream:

    fwrite(src, 1, 50000, dst); // will return 50000
    fwrite(src, 50000, 1, dst); // will return 1
    

    The speed might be implementation dependent although, I don't expect any considerable difference.

提交回复
热议问题