c - C语言中关于fopen、fwrite、fread的基本问题
问题描述
使用fopen(file, "r") 打开文件后,我可以使用fwrite()到文件还是只能使用fread()?
使用fopen(file, "w")打开文件后,我可以立即使用fopen(file, "a")将模式切换为追加而不使用 fclose() 吗?
解决方案
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
推荐阅读
- powershell - 根据用户名输入变量断开 RDS 用户
- javascript - 对 Google Calendar API 的请求问题
- javascript - 单击,触发动画和播放声音。从 keydown 到单击
- ios - 在不使用内置相机的情况下在 Swift 中使用 AVCaptureSession
- azure - 由于部署请求限制,无法预配此部署所需的 VM 大小(或 VM 大小的组合)
- laravel - Laravel 用碳计时
- javascript - document.querySelector 为使用 javascript 的 html 注入返回 null
- express - 使用 express 配置 amp cors
- python - Sklearn f-beta分数实现问题
- javascript - 如何向公众隐藏 HTML/CSS,最重要的是 app.js(Firebase 代码)?