what is r+ in FILE structure in C?

后端 未结 3 1308
孤街浪徒
孤街浪徒 2021-01-22 07:24

I am reading some C text at the address: https://cs.senecac.on.ca/~btp100/pages/content/files.html

in the section \"OPENING A FILE\", the author wrote:

相关标签:
3条回答
  • 2021-01-22 08:07

    When you open a file with "r+" then the file is open for reading and writing BUT the file must exist first. If you open it with "w" then the file will be created so it does not need to exist. Hope that helps.

    0 讨论(0)
  • 2021-01-22 08:08

    Of course, there are some writing into a file which can fail (think of a "disk is full" situation).

    The "possible writing" phrase means just that a FILE* handle fopen-ed with "r+" might be used without any write operations. For instance, if your application want to overwrite some part of the file only under some circumstances, it can avoid the writing.

    0 讨论(0)
  • 2021-01-22 08:21

    It's poor wording. It should be:

    r+
        Open file for update (reading and writing).
    
    0 讨论(0)
提交回复
热议问题