Difference between fclose and close

后端 未结 4 1731
终归单人心
终归单人心 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:46

    As for your second question, forked children have the same numeric file descriptor as the parent, but it's a copy; they can close it, and it will still be open for the parent and other children. (Though personally, I don't like to have files open when I fork()... I like to make that sort of shared resource usage explicit. Pipes, of course, are an exception.)

提交回复
热议问题