What is the difference between read() and fread()?

前端 未结 6 1289
你的背包
你的背包 2020-11-27 12:45

I\'m reading source code of the linux tool badblocks. They use the read() function there. Is there a difference to the standard C fread() function?

6条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 13:26

    As I remember it the read() level APIs do not do buffering - so if you read() 1 byte at a time you will have a huge perf penalty compared to doing the same thing with fread(). fread() will pull a block and dole it out as you ask for it. read() will drop to the kernel for each call.

提交回复
热议问题