- 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);
缓冲输入输出
最新推荐文章于 2023-11-27 10:40:19 发布