What happens to FILE pointer after file is closed?

前端 未结 4 1645
天涯浪人
天涯浪人 2020-12-06 01:48

I wish to know what happens to FILE pointer after the file is closed. Will it be NULL?

Basically, I want to check if a file has already been closed before closing a

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 02:19

    Since arguments are passed by value there is not way fclose could set your file pointer to NULL. Since fclose probably destroys the FILE you have to

    • Manually set the file pointer to NULL after doing a fclose (won't work if you close it in a different function unles you use FILE **)
    • Don't end up in a situation where you "forget" whether you closed it or not (might be tricky)

提交回复
热议问题