1.总览
Index | 函数名 | 用途描述与说明 | 返回值 |
1 | rewind | 设置文件位置指示器到文件的开头,等价于(void) fseek(stream, 0L, SEEK_SET) | 没有返回值 |
2 | feof | 测试指向的流中的文件结束标记,如果已设置就返回非零值。 | 这个函数不应当失败,它不设置外部变量 errno 。 (但是,如果 fileno 检测到它的参数不是有效的流,它必须返回 -1,并且将 errno 设置为 EBADF 。 ) |
3 | ftell | 获取当前文件位置指示 | 若成功则为当前文件位置指示,若出错则为-1L |
4 | fgets | fgets函数读入数据,直到行结束或缓存满(当然会留出一个字节存放终止字符). | |
2.分述
2.1 rewind
#include
void rewind(FILE *stream);
The rewind() function sets the file position indicator for the stream pointed to by
stream to the beginning of the file. It is equivalent to:
(void) fseek(stream, 0L, SEEK_SET)
The rewind() function returns no value.
2.2 feof
tests the end-of-file indicator for the stream pointed to by stream.
测试指向的流中的文件结束标记,如果已设置就返回非零值。
文件结束标记只能用函数clearerr清除.
2.3 ftell
The ftell() function obtains the current value of the file position indicator for the
stream pointed to by stream.
The rewind() function returns no value. Upon successful completion, fgetpos(),
fseek(),fsetpos() return 0, and ftell() returns the current offset. Otherwise,
-1 is returned and errno is set to indicate the error.
2.4 fgets
#include
char *fgets(char *s, int size, FILE *stream);
fgets() reads in at most one less than size characters from stream and stores them
into the buffer pointed to by s. Reading stops after an EOF or a newline.
If a newline is read, it is stored into the buffer. A terminating null byte ('\0')
is stored after the last character in the buffer.
gets() and fgets() return s on success, and NULL on error or when end of file occurs
while no characters have been read.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)