全缓冲:缓冲区被填满才使用系统调用。
行缓冲:如果遇到换行符,则使用系统调用
无缓冲:没有缓冲区,数据会实时立刻读入或者输出。
缓冲区函数的设置
int setvbuf(FILE *stream ,char *buf ,int mode ,size_t size)
其中stream为流指针,buf为缓冲区的 长度,mode参数为三个参数_IOFBF ,(全缓冲) _IOLBF(行缓冲)和——IONBF(不带缓冲)
流的读写
字符读写:int fgetc(FILE *stream);
int getc(FILE *stream); 写完这个函数就会创建stream流文件,输入字符。
int fputc(int c , FILE *stream)
int puc(int c , FILE *stream); 输出字符
行读写:fgets (char *s , int size , FILE * stream)
fputs(const char *s FILE *stream);
流的出错判断
ferror (FILE *stream) 文件错误就返回0,正确则返回非0值
feof(FILE *stream )
l流的冲洗
fflush(FILE * stream)