c语言文件打开方式问题?

来源:百度知道 编辑:UC知道 时间:2024/05/22 01:37:37
我用C语言,做文件处理.
1,什么样的打开方式,能读能写;
2,什么样的打开方式,当文件已经存在是,不要清空文件已有的内容且能对文件进行读和写.
fopen("123",mode);
这个mode用什么类型能完成上述功能;

如果你用的是VC,并且安装了MSDN,请在索引中输入“fopen”就可以看到此函数的完整说明,粘贴一部分:
"r"

Opens for reading. If the file does not exist or cannot be found, the fopen call fails.

"w"

Opens an empty file for writing. If the given file exists, its contents are destroyed.

"a"

Opens for writing at the end of the file (appending) without removing the EOF marker before writing new data to the file; creates the file first if it doesn’t exist.

"r+"

Opens for both reading and writing. (The file must exist.)

"w+"

Opens an empty file for both reading and writing. If the given file exists, its contents are destroyed.

"a+"

Opens for reading and appending; the appending operation includes the removal of the EOF marker before new data is written to the file and the EOF marker is restored after writing is complete; creates the file first if it does