FILE* fopen(const char* restrict pathname, const* restrict type);
成功返回文件指针,失败返回 NULL,errno 提示出错的性质———需要判断打开流的执行情况
FILE *fclose(FILE *stream)
返回值 :失败返回EOF
void perror(const char *s);
char *strerror(int errnum);
int fgetc(FILE *stream);
返回值: 成功返回读入的字符,失败或者读到文件的末尾返回EOF;
int fputc(int c, FILE *stream);
返回值: 成功返回一个非负数,写入失败返回EOF;
char *fgets(char *s, int size, FILE *stream);
返回值:成功返回缓冲区首地址,读到 ‘\n’ 或者 size - 1 个字符结束,后面补充 ‘\0‘ (在终端输入 ‘\n’ ,那么后面会添加 ‘\0’ 作为结束)
int fputs(const char *s, FILE *stream);
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
成功返回实际读到的个数,读到文件末尾返回 0 ;
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
返回值:实际写入的个数
int feof(FILE *stream);
返回值 :流到达末尾返回1,没到末尾返回0
int ferror(FILE *stream);
判断流是否出错,有错误发生返回非0;
int fseek(FILE *stream, long offset, int whence);
whence :流指针的位置SEEK_SET : 文件的开头
SEEK_END : 文件的末尾
SEEK_CUR :文件流指针的当前位置返回值 : 调用成功返回0,失败返回 -1
long ftell(FILE *stream);
返回当前流指针指向的位置
void rewind(FILE *stream);
int fflush(FILE *stream);
返回值: 成功返回0,失败返回EOF;
int fprintf(FILE *stream, const char *format, ...)
int sprintf(char *str, const char *format, ...);
成功返回0,失败返回-1;
int sscanf(const char *str, const char *format, ...);
原文:https://www.cnblogs.com/tranErmu/p/15194987.html