留心一下fopen打开文件的模式
2013-04-08 22:14
323 查看
函数原型:
FILE *fopen(const char *path, const char *mode);
打开模式详解:
r Open text file for reading. The stream is positioned at the
beginning of the file.
r+ Open for reading and writing. The stream is positioned at the
beginning of the file.
w Truncate file to zero length or create text file for writing.
The stream is positioned at the beginning of the file.
w+ Open for reading and writing. The file is created if it does
not exist, otherwise it is truncated. The stream is positioned
at the beginning of the file.
a Open for appending (writing at end of file). The file is cre-
ated if it does not exist. The stream is positioned at the end
of the file.
a+ Open for reading and appending (writing at end of file). The
file is created if it does not exist. The initial file position
for reading is at the beginning of the file, but output is
always appended to the end of the file.
需要注意如下的两点(个人在前段时间遇到的):
(1) "r" 与 "r+"的区别;后者打开的文件具有写权限
(2) "rw" 与 "wr"的区别;在fopen一个当前不存在的文件时,前者会core掉
FILE *fopen(const char *path, const char *mode);
打开模式详解:
r Open text file for reading. The stream is positioned at the
beginning of the file.
r+ Open for reading and writing. The stream is positioned at the
beginning of the file.
w Truncate file to zero length or create text file for writing.
The stream is positioned at the beginning of the file.
w+ Open for reading and writing. The file is created if it does
not exist, otherwise it is truncated. The stream is positioned
at the beginning of the file.
a Open for appending (writing at end of file). The file is cre-
ated if it does not exist. The stream is positioned at the end
of the file.
a+ Open for reading and appending (writing at end of file). The
file is created if it does not exist. The initial file position
for reading is at the beginning of the file, but output is
always appended to the end of the file.
需要注意如下的两点(个人在前段时间遇到的):
(1) "r" 与 "r+"的区别;后者打开的文件具有写权限
(2) "rw" 与 "wr"的区别;在fopen一个当前不存在的文件时,前者会core掉
相关文章推荐
- 解析php中的fopen()函数用打开文件模式说明
- php中fopen() 函数用打开文件模式说明
- 解析php中的fopen()函数用打开文件模式说明
- fopen打开文件的模式详解
- fopen中文件的几种打开模式比较
- [转]c的fopen()打开文件的模式,第二个参数
- fopen文件打开模式
- fopen打开文件模式rb和rb+有什么区别
- linux文件打开模式
- 以写模式打开一个文件
- C语言文件打开的模式
- python基础-打开模式、seek、修改文件、with上下文管理、truncate
- 打开文件的模式
- Python打开文件的模式
- 最近用360浏览器访问自己的网站,发现都是被优先选用兼容模式打开,这使得网站很难看。为了让360浏览器打开网站的时候优先试用极速模式,找了一下官方论坛,发现了解决方案。
- Qt、Vc下用fopen打开中文名字的文件
- c++文件打开模式的有效组合
- fopen多次打开同一个文件
- fopen 打开模式总结
- 打开的文件符合PDF/A标准,且已在只读模式下打开,以防被修改