Chinaunix首页 | 论坛 | 博客
  • 博客访问: 581044
  • 博文数量: 126
  • 博客积分: 4379
  • 博客等级: 上校
  • 技术积分: 2110
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-06 22:35
文章分类

全部博文(126)

文章存档

2012年(5)

2011年(3)

2010年(2)

2009年(116)

分类: LINUX

2009-02-20 07:35:10

3、标准I/O

(1)#include

       FILE *fopen(const char *restrict pathname, const char *restrict type);

       FILE *freopen(const char *restrict pathname, const char *restrict type, FILE *restrict fp);

       FILE *fdopen(int fds, const char *type);

                                                               若成功则返回文件指针,若出错则返回NULL

Typerwar+w+a+

       int fclose(FILE *fp);

                                                                      若成功则返回0,若出错则返回NULL

(2) #include

       int getc(FILE *fp);                             每次一个字符的I/O

       int fgetc(FILE *fp);

       int getchar(void);

                                                 若成功则返回下一个字符,若已达到文件结尾或出错则返回EOF

       int ferror(FILE *fp);

       int feof(FILE *fp);

       void clearerr(FILE *fp);

                                                                             若条件为真则返回非0值,否则返回0

       int putc(int c, FILE *fp);

int fputc(int c, FILE *fp);

int putchar(int c);

                                                                      若成功则返回c,若出错则返回EOF

       char *fgets(char *restrict buf, int n, FILE *restrict fp);     每次一行I/O

       char *gets(char *buf);

                                                 若成功则返回buf,若已达到文件结尾或出错则返回EOF

       int *fputs(const char *restrict str, FILE *restrict fp);

       int *puts(const char *str);

                                                                      若成功则返回非负值,若出错则返回EOF

 

       size_t fread(void *restrict buf, size_t size, size_t nobj, FILE *restrict fp);

       size_t fwrite(const *restrict buf, size_t size, size_t nobj, FILE *restrict fp);

                                                                             读或写的对象数

(3) #include

       long ftell(FILE *fp);

       off_t ftell(FILE *fp);

 

                                                                      若成功则返回当前文件位置指示,若出错则返回-1L

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

       int fseek(FILE *fp, off_t offset, int whence);

 

                                                                             若成功则返回0,若出错则返回非0

       void rewind(FILE *fp);

 

       int fgetpos(FILE *restrict fp, fops_t *restrict pos);

       int fsetpos(FILE *fp, const fops_t *pos);

                                                                             若成功则返回0,若出错则返回非0

(4) #include

       int printf(const char *restrict format, …);

       int fprintf(FILE *restrict fp, const char *restrict format, …);

                                                                      若成功则返回输出字符数,若出错则返回负值

       int sprintf(char *restrict buf, const char *restrict format, …);

       int snprintf(char *restrict buf, size_t n, const char *restrict format, …);

                                                                      若成功则返回存入数组的字符数,若出错则返回负值

       int scanf(const char *restrict format, …);

       int fscanf(FILE *restrict fp, const char *restrict format, …);

       int sscanf(char *restrict buf, const char *restrict format, …);

                                          指定的输入项数,若输入出错或在任意变换前已到达文件结尾则返回EOF

(5)#include

       int fileno(FILE *fp);

阅读(1017) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~