Linux 标准I/O流学习
来源:互联网 发布:淘宝儿童女装秋装 编辑:程序博客网 时间:2024/04/24 16:53
今天开始学习linux编程,以下是自己感觉有用的些摘要,作为学习笔记,以见证我的学习!
包含头文件<stdio.h>
1 打开和关闭流
FILE * fopen (const char* path,const char * mode );
FILE * freopen (const char *path,const char * mode,FILE *stream);
将原stream所打开的文件流关闭,然后打开参数path的文件
FILE *fp;
fp = fopen("a.txt", "r");
fp = freopen("b.txt", "r", fp); /* 改fp指向b.txt, 并关闭a.txt */
fclose(fp);
FILE * fdopen (int filde,const char * mode);
???????????
int * fclose (FILE * stream);
2 流的读写
(1)读写数据块
int fread(void *ptr, int size, int nitems, FILE *stream);
用于接收数据的地址(ptr)
单个元素的大小(size)
元素个数(nitems)
提供数据的文件指针(stream)
返回值:成功读取的元素个数
int fwrite(const void *ptr, int size, int nitems, FILE *stream);
(2)读写字符
int fgetc(FILE * stream);返回读取到的字符
int fputc(int c,FILE * stream);
如果失败都返回EOF
(3)读写字符串
char *fgets(char *s,int size,FILE * stream);成功返回缓冲区指针s,失败NULL
int *fputs(const char*s,FILE * stream);失败返回EOF
3 定位流
void rewind(FILE * stream);将文件指针重新指向一个流的开头
int fseek(FILE *stream, long offset, int fromwhere);重定位流stream为从fromwhere开始的offset处
long ftell(FILE * stream);返回当前位置,失败-1
4 流的检测
int feof(FILE *stream);检查是否处于文件结束位置,是返回1,否返回0
包含头文件<stdio.h>
1 打开和关闭流
FILE * fopen (const char* path,const char * mode );
FILE * freopen (const char *path,const char * mode,FILE *stream);
将原stream所打开的文件流关闭,然后打开参数path的文件
FILE *fp;
fp = fopen("a.txt", "r");
fp = freopen("b.txt", "r", fp); /* 改fp指向b.txt, 并关闭a.txt */
fclose(fp);
FILE * fdopen (int filde,const char * mode);
???????????
int * fclose (FILE * stream);
2 流的读写
(1)读写数据块
int fread(void *ptr, int size, int nitems, FILE *stream);
用于接收数据的地址(ptr)
单个元素的大小(size)
元素个数(nitems)
提供数据的文件指针(stream)
返回值:成功读取的元素个数
int fwrite(const void *ptr, int size, int nitems, FILE *stream);
(2)读写字符
int fgetc(FILE * stream);返回读取到的字符
int fputc(int c,FILE * stream);
如果失败都返回EOF
(3)读写字符串
char *fgets(char *s,int size,FILE * stream);成功返回缓冲区指针s,失败NULL
int *fputs(const char*s,FILE * stream);失败返回EOF
3 定位流
void rewind(FILE * stream);将文件指针重新指向一个流的开头
int fseek(FILE *stream, long offset, int fromwhere);重定位流stream为从fromwhere开始的offset处
long ftell(FILE * stream);返回当前位置,失败-1
4 流的检测
int feof(FILE *stream);检查是否处于文件结束位置,是返回1,否返回0
- Linux 标准I/O流学习
- linux学习---文件I/O和标准I/O
- Linux标准I/O
- 标准I/O流
- Linux 标准I/O函数库
- Linux 标准I/O函数库
- Linux系统编程学习之《标准I/O操作》
- Linux学习笔记三,标准I/O库
- Linux学习总结(四)——标准I/O与文件I/O
- Linux初学实战之重定向标准 I/O 流
- java 标准I/O流
- 标准的I/O流
- Linux - 标准I/O库与高级I/O库
- Java 标准 I/O 流编程学习笔记(上)
- Java 标准 I/O 流编程学习笔记(下)
- UNIX环境编程学习笔记—文件I/O之标准I/O流
- linux c标准I/O函数
- Linux标准I/O(一)
- LINUX命令大全
- 设计模式---单件(C++版) 一个简单实例(避免用户忘记delete单件实例)
- 占位:
- asp.net Ajax--Calendar控件使用
- 占位:
- Linux 标准I/O流学习
- 不要做浮躁的人
- ARP欺骗病毒
- CODE阶段的架构设计
- oracle 权限与角色
- leo谈“80后”程序员为什么找不到工作?
- Web Services横空出世
- matlab 计算程序运行时间 的几个函数
- 许三多:浮躁社会的反义词