none
FILE 指针如何释放? RRS feed

  • 问题

  • 我用下面方式打开文件,请问writeFile这个指针如何释放,写入文件完毕,如何关闭文件访问?

    FILE *writeFile=fopen("C:\\test\\20140816_02.jpg","wb");

    2014年8月18日 7:24

答案

  • fclose(writeFile);

    Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.

    2014年8月19日 1:42
    版主
  • 你好,

    除了 VisualEleven 建议的fclose,如果你同时操作了多个文件指针,还可以考虑用 _fcloseall( )。

    除此之外,当你关闭了文件流之后,为了确保后续操作不出现问题,你可以将文件指针设为空。以下这个帖子,你可以参考一下,也许对你有帮助。

    why does fclose not set file pointer to NULL?

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年8月19日 3:28

全部回复

  • fclose(writeFile);

    Visual C++ enthusiast, like network programming and driver development. At present is being engaged in the WinCE/Windows Mobile platform embedded development.

    2014年8月19日 1:42
    版主
  • 你好,

    除了 VisualEleven 建议的fclose,如果你同时操作了多个文件指针,还可以考虑用 _fcloseall( )。

    除此之外,当你关闭了文件流之后,为了确保后续操作不出现问题,你可以将文件指针设为空。以下这个帖子,你可以参考一下,也许对你有帮助。

    why does fclose not set file pointer to NULL?

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2014年8月19日 3:28