Chinaunix首页 | 论坛 | 博客
  • 博客访问: 129533
  • 博文数量: 44
  • 博客积分: 956
  • 博客等级: 准尉
  • 技术积分: 521
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-18 12:45
文章分类
文章存档

2012年(11)

2011年(33)

分类: C/C++

2011-12-28 19:29:21

ANSI C: 库,缓冲,
高级磁盘IO:
strace:系统跟踪命令,
strace ./a.out
FILE *fopen(const char *path, const char *mode);
r 只读,文件必须存在
r+读写,文件必须存在
w 只写,会从头开始覆盖,不存在则会创建
w+读写,会从头开始覆盖,不存在则会创建
a 追加写,不存在则会创建
a+追加读写
int fclose(FILE *stream);
int getc(FILE *stream);  //宏实现
int fgetc(FILE *stream);
int getchar(void);//等于 int getc(stdin);
int putc(int c, FILE *stream);
int putchar(int c)//等于:int putc(int c, stdout);
int fputc(int c, FILE *stream);
perror();
strerror(errno);
buf[strlen(buf)-1] == '\n';
int fputs(char *buf, FILE *stream);
char *fgets(char *buf, size_t size, FILE *stream);
一个linux默认最多能打开1024(包括标准IO和错误)
size_t fread       (void *ptr, size_t size, size_t nmemb, FILE *stream);
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FIle *stream);
int fseek(FILE *stream, long offset, int wherece);
offset:+向后偏移,-向前偏移
wherece:基准,SEEK_SET文件开始,SEEK_END文件结束,SEEK_CUR当前位置;
返回:
long ftell(FILE *stream);
void rewind(FILE *stream);

FILE *freopen(const char *path, const char *mode, FILE *stream);将流进行重新定向~
阅读(1068) | 评论(0) | 转发(0) |
0

上一篇:Qt使用基础(15)

下一篇:文件IO(17)

给主人留下些什么吧!~~