Is there any ordinary reason to use open() instead of fopen()?

前端 未结 7 1285
南旧
南旧 2021-01-05 13:05

I\'m doing a small project in C after quite a long time away from it. These happen to include some file handling. I noticed in various documentation that there are functions

相关标签:
7条回答
  • 2021-01-05 13:53

    fopen and its cousins are buffered. open, read, and write are not buffered. Your application may or may not care.

    fprintf and scanf have a richer API that allows you to read and write formatted text files. read and write use fundamental arrays of bytes. Conversions and formatting must be hand crafted.

    The difference between file descriptors and (FILE *) is really inconsequential.

    Randy

    0 讨论(0)
提交回复
热议问题