总结:EOF只是函数的一个返回值,值为十进制-1,十六进制为0xFF,本质上为函数的一个返回值,文件中并不存在EOF
我们先一起来看看FILE是怎么定义的:
FILE <STDIO.H>
File control structure for streams.
typedef struct {
short level;
unsigned flags; char fd;
unsigned char hold;
short bsize;
unsigned char *buffer, *curp;
unsigned istemp;
short token;
} FILE;
再来看看这个flags是怎么定义的:
_F_xxxx <STDIO.H>
File status flags of streams
Name ?Meaning
_F_RDWR ?Read and write
_F_READ ?Read-only file
_F_WRIT ?Write-only file
_F_BUF ?Malloc'ed buffer data
_F_LBUF ?Line-buffered file
_F_ERR ?Error indicator
_F_EOF ?EOF indicator
我们先一起来看看FILE是怎么定义的:
FILE <STDIO.H>
File control structure for streams.
typedef struct {
short level;
unsigned flags; char fd;
unsigned char hold;
short bsize;
unsigned char *buffer, *curp;
unsigned istemp;
short token;
} FILE;
再来看看这个flags是怎么定义的:
_F_xxxx <STDIO.H>
File status flags of streams
Name ?Meaning
_F_RDWR ?Read and write
_F_READ ?Read-only file
_F_WRIT ?Write-only file
_F_BUF ?Malloc'ed buffer data
_F_LBUF ?Line-buffered file
_F_ERR ?Error indicator
_F_EOF ?EOF indicator