首页 > 解决方案 > C语言中关于fopen、fwrite、fread的基本问题

问题描述

使用fopen(file, "r") 打开文件后,我可以使用fwrite()到文件还是只能使用fread()

使用fopen(file, "w")打开文件后,我可以立即使用fopen(file, "a")将模式切换为追加而不使用 fclose() 吗?

标签: c

解决方案


It all depends on the mode which you have given
    mode    description
    r   opens a text file in reading mode
    w   opens or create a text file in writing mode.
    a   opens a text file in append mode
    r+  opens a text file in both reading and writing mode
    w+  opens a text file in both reading and writing mode
    a+  opens a text file in both reading and writing mode
    rb  opens a binary file in reading mode
    wb  opens or create a binary file in writing mode
    ab  opens a binary file in append mode
    rb+ opens a binary file in both reading and writing mode
    wb+ opens a binary file in both reading and writing mode
    ab+ opens a binary file in both reading and writing mode

有关更多信息,请使用以下链接https://www.studytonight.com/c/file-input-output.php


推荐阅读