C语言笔记之文件输入输出

<stdio.h>支持文本文件和二进制文件。

文件操作

1.文件打开 FILE* fopen(const char * restrict filename,const char*restrict mode);
注意:fopen函数调用的文件名中含有字符\时。c语言会把\看成转义字符。
如:fopen(“c:\project\test1.dat”,“r”);
正确避免方式:
1)fopen(“c:\project\test1.dat”,“r”);
2)fopen(“c:/project/test1.dat”,“r”);
当fopen返回空指针时,可能是因为文件不存在、位置不对、没有打开的权限

2.模式:
C语言笔记之文件输入输出
C语言笔记之文件输入输出

3.文件关闭
fclose(FILE *stream)

相关文章:

  • 2021-12-23
  • 2021-10-15
  • 2022-12-23
  • 2022-01-27
  • 2021-11-13
  • 2022-02-04
  • 2021-11-25
  • 2021-05-23
猜你喜欢
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
  • 2021-12-16
  • 2022-12-23
  • 2021-11-28
相关资源
相似解决方案