操作读写位置函数

rewind 把读写位置移动到文件开头

fseek可以任意移动读写位置

ftell可以返回当前的读写位置;

#include <stdio.h>

int fseek(FILE *stream,long offset,int whence);

long ftell(FILE *stream);

void rewind(FILE *stream);

whence参数含义

SEEK_SET 从文件开头移动offset个字节;

SEEK_CUR 从当前位置移动offset个字节;

SEEK_END 从文件末尾移动offset个字节;

offset可正值可负数,负数表示向前(向文件开头方向),正值表示向文件尾部移动

以字符串为单位的I/O函数

int fputs(const char *s,FILE *stream);

int puts(const char *s);

int fgets(char *s,int size,FILE *stream);

05-11 17:12
查看更多