【发布时间】:2013-02-17 12:54:47
【问题描述】:
今天我在学习C的标准I/O。当我打开stdio.h文件时发现:
typedef struct _iobuf FILE;
当检查 struct _iobuf 的定义时发现:
struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
为了了解更多,我已经给出了关于每个不正确与否的描述
struct _iobuf {
char *_ptr; /* next character position */
int _cnt; /* characters left */
char *_base; /* location of buffer */
int _flag; /* File status flags */
int _file;
int _charbuf; /*Data transfer buffer */
int _bufsiz; /* Buffer size */
char *_tmpfname; /* Temporary file indicator */
};
现在我有两个问题?
Q1:我是否提供了正确的名称以及 I/O 中的结构如何提供帮助,如果我添加或删除任何东西会发生什么?这会相应地工作吗?这里提供的顺序重要吗?
Q2:这里没有使用指针,为什么要使用FILE *来打开文件?
【问题讨论】:
标签: c visual-c++ gcc cross-platform c99