缓冲输入输出


1.fopen()打开文件,返回流
FILE* fopen(const char * path, const char * mode);
2.fdopen()通过文件描述符打开文件
FILE * fdopen (int fd, const char *mode);
3.fclose()关闭文件
int fclose (FILE *stream);
4.fcloseall()关闭所有文件
int fcloseall (void);
5.fgetc()读取单个字符
int fgetc (FILE *stream);
6.ungetc()将字符放回流
int ungetc (int c, FILE *stream);
7.fgets()按行读取字符串
char * fgets (char *str, int size, FILE *stream);
8.fread()读取二进制
size_t fread (void *buf, size_t size, size_t nr,FILE *stream);
9.fputc()写入单个字符
int fputc (int c, FILE *stream);
10.fputs()写入字符串
int fputs (const char *str, FILE *stream);
11.fwrite()写入二进制数据
size_t fwrite (void *buf,size_t size,size_t nr,FILE *stream);
12.定位流
fseek()函数
int fseek (FILE *stream, long offset, int whence);//将流设置到whence规定的offset处(whence的取值可以是SEEK_SET、SEEK_CUR、SEEK_END)
fsetpos()函数
int fsetpos (FILE *stream, fpos_t *pos);//将流设置到pos处
rewind()函数
void rewind (FILE *stream);//将流设置到开始位置
13.ftell()返回当前流的位置
long ftell (FILE *stream);
14.fgetpos()获得当前流的位置设置到pos中
int fgetpos (FILE *stream, fpos_t *pos);
15.fflush()将数据刷到内核缓冲区中
int fflush (FILE *stream);
16.ferror()检测错误标志
int ferror (FILE *stream);
17.feof()检测文件结尾标志
int feof (FILE *stream);
18.clearerr()清空错误和文件结尾标志
void clearerr (FILE *stream);
19.fileno()获取文件描述符
int fileno (FILE *stream);
20.setvbuf()设置一个指向buf区域size大小的缓冲,mode表示缓冲模式(_IONBF、_IOLBF、_IOFBF)
int setvbuf (FILE *stream, char *buf, int mode,size_t size);
21.flockfile()文件加锁
void flockfile (FILE *stream);
22.funlockfile()、ftrylockfile()减少与流相关的锁计数
void funlockfile (FILE *stream);
int ftrylockfile (FILE *stream);
23.不加锁函数
int fgetc_unlocked (FILE *stream);
char *fgets_unlocked (char *str, int size, FILE *stream);
size_t fread_unlocked (void *buf, size_t size,size_t nr,FILE *stream);
int fputc_unlocked (int c, FILE *stream);
int fputs_unlocked (const char *str, FILE *stream);
size_t fwrite_unlocked (void *buf, size_t size,size_t nr,FILE *stream);
int fflush_unlocked (FILE *stream);
int feof_unlocked (FILE *stream);
int ferror_unlocked (FILE *stream);
int fileno_unlocked (FILE *stream);
void clearerr_unlocked (FILE *stream);






  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sjiang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值