fopen函数中的mode参数
fopen
- FILE * fopen ( const char * filename, const char * mode );
- 其中,参数mode可取以下值:
"r"
read: Open file for input operations. The file must exist.
"w"
write: Create an empty file for output operations. If a file with the same name already exists, its contents are discarded and the file is treated as a new empty file.
"a"
append: Open file for output at the end of a file. Output operations always write data at the end of the file, expanding it. Repositioning operations (fseek, fsetpos, rewind) are ignored. The file is created if it does not exist.
"r+"
read/update: Open a file for update (both for input and output). The file must exist.
"w+"
write/update: Create an empty file and open it for update (both for input and output). If a file with the same name already exists its contents are discarded and the file is treated as a new empty file.
"a+"
append/update: Open a file for update (both for input and output) with all output operations writing data at the end of the file. Repositioning operations (fseek, fsetpos, rewind) affects the next input operations, but output operations move the position back to the end of file. The file is created if it does not exist.
需要注意的是,对于 ”a” 或 “a+”,fseek, fsetpos, rewind 等重新定准的函数都是无效的,所有新写入的数据均追加至文件末尾。
参考资料:
http://www.cplusplus.com/reference/cstdio/fopen/
fopen函数中的mode参数的更多相关文章
- linux中probe函数中传递的参数来源(上)
点击打开链接 上一篇中,我们追踪了probe函数在何时调用,知道了满足什么条件会调用probe函数,但probe函数中传递的参数我们并不知道在何时定义,到底是谁定义的,反正不是我们在驱动中定义的(当然 ...
- fopen()函数中参数mode的取值
FILE * fopen(const char * path,const char * mode); 参数mode字符串则代表着流形态. mode有下列几种形态字符串: r 打开只读文件,该文件必须存 ...
- C语言-一个fopen函数中未使用二进制模式(b)引发的血案
转自:http://blog.csdn.net/hinyunsin/article/details/6401854 最近写了一个网络文件传输模块,为了让这个模块具有更好的移植性,我尽量使用C标准IO ...
- Python函数中如何定义参数
一.位置参数:根据函数定义时的参数位置传递参数#形参和实参的个数必须一致def fun1(): print("运行结果") print("this is fun1(),n ...
- 从Win32程序中的主函数中获取命令行参数
在标准C或者Win32控制台程序的main函数中,它们都有两个参数:"argc" 和 "argv",如下所示: int main(int argc, char ...
- python:函数中五花八门的参数形式(茴香豆的『回』字有四种写法)
毫不夸张的说,python语言中关于函数参数的使用,是我见过最为灵活的,随便怎么玩都可以,本文以数学乘法为例,演示几种不同的传参形式: 一.默认参数 def multiply1(x, y): retu ...
- Python函数中的可变参数
在Python函数中,还可以定义可变参数. 如:给定一组数字a,b,c……,请计算a2 + b2 + c2 + ……. 要定义出这个函数,我们必须确定输入的参数.由于参数个数不确定,我们首先想到可以把 ...
- C/C++函数中使用可变参数
先说明可变参数是什么,先回顾一下C++里面的函数重载,如果重复给出如下声明: int func(); int func(int); int func(float); int func(int, int ...
- function(函数)中的动态参数
我们可向函数传递动态参数,*args,**kwargs,首先我们来看*args,示例如下: 1.show(*args) def show(*args): print(args,type(arg ...
随机推荐
- Blazor WebAssembly 船新项目下载量测试 , 仅供参考.
前言: 昨天 Blazor WebAssembly 3.2 正式发布了. 更新 VS2019后就能直接使用. 新建了两个PWA项目, 一个不用asp.net core (静态部署), 一个使用as ...
- Python创建一个简单的区块链
区块链(Blockchain)是一种分布式账本(listributed ledger),它是一种仅供增加(append-only),内容不可变(immutable)的有序(ordered)链式数据结构 ...
- Maven系列(一) -- maven仓库的搭建
从今天开始,我要写一个maven系列的文章,以帮助大家来更好的熟悉maven仓库,并且将自己优秀的的代码开源出去,一方面为开源做贡献,另一方面顺便提升自己的知名度,让我们把愉快的开始吧 为什么要搭建m ...
- java中碰到的异常
mapper接口中找不到相应方法 解决:配置xml读取路径错误 org.apache.ibatis.binding.BindingException: Invalid bound statement ...
- Java-KTVByLinkedList模拟点歌工具
import java.util.LinkedList; import java.util.Scanner; public class KTVByLinkedList { public static ...
- Python的自定义属性访问跟描述器以及ORM模型的简单介绍
一 . 自定义属性访问 1.__getattr__ 作用:当我们访问属性的时候,如果属性不存在(出现AttrError),该方法会被触发. 2.__getattribute__ 作用:访问属性的时候, ...
- 【C++】赋值过程中类型转换
注意:以下内容摘自文献[1],修改了部分内容. 1.赋值过程中的类型转换 如果赋值运算符两侧的类型不一致,但都是数值型或字符型时,在赋值时自动进行类型转换. (1) 将浮点型数据(包括单.双精度)赋给 ...
- 设置Mac终端、pip、Anaconda、PyCharm共用一套环境
最近我在用Macbook Pro练习PyTorch的时候,发现明明在终端已经用pip安装了PyTorch,但在pycharm运行时总是报错:No module named torch. 但是我把同样的 ...
- ElementUi 全选功能实现
每次使用官方的示例都会被坑一下(可能是我的理解不够透彻吧,不记录一下保不准下次依旧会忘), 故此今天做个Demo 记录一下.本次仍然使用官网给出的示例,只做理解性的说明. 1.此处先给出官方示例代码: ...
- Web缓存欺骗
该漏洞主要是cdn安全配置的问题,cdn主要存储以下文件,加快访问速度 class, css, jar, js, jpg, jpeg, gif, ico, png, bmp, pict, csv, d ...