缓冲输入输出

来源:互联网 发布:百分百软件破解版 编辑:程序博客网 时间:2024/05/16 07:23
[cpp] view plaincopy
  1. 1.fopen()打开文件,返回流  
  2. FILE* fopen(const char * path, const char * mode);  
  3. 2.fdopen()通过文件描述符打开文件  
  4. FILE * fdopen (int fd, const char *mode);  
  5. 3.fclose()关闭文件  
  6. int fclose (FILE *stream);  
  7. 4.fcloseall()关闭所有文件  
  8. int fcloseall (void);  
  9. 5.fgetc()读取单个字符  
  10. int fgetc (FILE *stream);  
  11. 6.ungetc()将字符放回流  
  12. int ungetc (int c, FILE *stream);  
  13. 7.fgets()按行读取字符串  
  14. char * fgets (char *str, int size, FILE *stream);  
  15. 8.fread()读取二进制  
  16. size_t fread (void *buf, size_t size, size_t nr,FILE *stream);  
  17. 9.fputc()写入单个字符  
  18. int fputc (int c, FILE *stream);  
  19. 10.fputs()写入字符串  
  20. int fputs (const char *str, FILE *stream);  
  21. 11.fwrite()写入二进制数据  
  22. size_t fwrite (void *buf,size_t size,size_t nr,FILE *stream);  
  23. 12.定位流  
  24. fseek()函数  
  25. int fseek (FILE *stream, long offset, int whence);//将流设置到whence规定的offset处(whence的取值可以是SEEK_SET、SEEK_CUR、SEEK_END)  
  26. fsetpos()函数  
  27. int fsetpos (FILE *stream, fpos_t *pos);//将流设置到pos处  
  28. rewind()函数  
  29. void rewind (FILE *stream);//将流设置到开始位置  
  30. 13.ftell()返回当前流的位置  
  31. long ftell (FILE *stream);  
  32. 14.fgetpos()获得当前流的位置设置到pos中  
  33. int fgetpos (FILE *stream, fpos_t *pos);  
  34. 15.fflush()将数据刷到内核缓冲区中  
  35. int fflush (FILE *stream);  
  36. 16.ferror()检测错误标志  
  37. int ferror (FILE *stream);  
  38. 17.feof()检测文件结尾标志  
  39. int feof (FILE *stream);  
  40. 18.clearerr()清空错误和文件结尾标志  
  41. void clearerr (FILE *stream);  
  42. 19.fileno()获取文件描述符  
  43. int fileno (FILE *stream);  
  44. 20.setvbuf()设置一个指向buf区域size大小的缓冲,mode表示缓冲模式(_IONBF、_IOLBF、_IOFBF)  
  45. int setvbuf (FILE *stream, char *buf, int mode,size_t size);  
  46. 21.flockfile()文件加锁  
  47. void flockfile (FILE *stream);  
  48. 22.funlockfile()、ftrylockfile()减少与流相关的锁计数  
  49. void funlockfile (FILE *stream);  
  50. int ftrylockfile (FILE *stream);  
  51. 23.不加锁函数  
  52. int fgetc_unlocked (FILE *stream);  
  53. char *fgets_unlocked (char *str, int size, FILE *stream);  
  54. size_t fread_unlocked (void *buf, size_t size,size_t nr,FILE *stream);  
  55. int fputc_unlocked (int c, FILE *stream);  
  56. int fputs_unlocked (const char *str, FILE *stream);  
  57. size_t fwrite_unlocked (void *buf, size_t size,size_t nr,FILE *stream);  
  58. int fflush_unlocked (FILE *stream);  
  59. int feof_unlocked (FILE *stream);  
  60. int ferror_unlocked (FILE *stream);  
  61. int fileno_unlocked (FILE *stream);  
  62. void clearerr_unlocked (FILE *stream);  
0 0
原创粉丝点击