Difference between fclose and close

后端 未结 4 1746
终归单人心
终归单人心 2020-12-31 14:50

If I fopen a file, what\'s the difference between calling fclose or close and which one should I use?

If forked children have

4条回答
  •  我在风中等你
    2020-12-31 15:35

    open() and close() are UNIX syscalls which return and take file descriptors, for use with other UNIX syscalls such as write(). fopen() and fclose() are standard C library functions which operate on FILE*s, for use with things like fwrite and fprintf. The latter are almost always what you should be using: They're simpler and more cross-platform.

提交回复
热议问题