标签:lib 参考 can eof 格式 设置 编程 put crash
本文重点说明下面内容:
Application buff
|
clib buff
|
page cache
|
disk cache
#include <stdio.h>
//打开流
FILE *fopen(const char *pathname, const char *type);
//关闭流
int fclose(File *fp);
// 刷新流
int fflush(FILE *fp);
// 一次读写一个字符
int fgetc(FILE *fp);
int fputc(FILE *fp);
// 一次读写一行
char* fgets(char* buf, int n, FILE* fp);
int fputs(const char *str, FILE* fp);
// 二进制读写
size_t fread(void *ptr, size_t size, size_t nobj, FILE *fp);
size_t fwrite(const void *ptr, size_t size, size_t nobj, FILE *fp);
// 格式化输入输出
int fprintf(FILE *fp, const char* format, ...);
int fscanf(FILE *fp, const char *format, ...);
// 示例
#include <stdio.h>
#include <stdlib.h>
int main(void){
char buf[1024];
while (fgets(buf, 1024, stdin) != NULL)
if (fputs(buf, stdout) == EOF)
printf("output error");
if (ferror(stdin))
printf("input error");
exit(0);
}
说明
文件IO是直接操作linux系统调用,大部分的问题都是使用文件IO带来的。
API
标签:lib 参考 can eof 格式 设置 编程 put crash
原文地址:https://www.cnblogs.com/holidays/p/linux_io.html