rewind (C程序中的库函数)
2016-07-15 09:16
756 查看
C 程序中的库函数,功能是将文件内部的指针重新指向一个流的开头
中文名rewind含 义函数名功 能指向一个数据流/文件的开头用 法void rewind
2英文解释
3程序例
函数名: rewind()
功 能: 将文件内部的位置指针重新指向一个流(数据流/文件)的开头
注意:不是文件指针而是文件内部的位置指针,随着对文件的读写文件的位置指针(指向当前读写字节)向后移动。而文件指针是指向整个文件,如果不重新赋值文件指针不会改变。
rewind函数作用等同于 (void)fseek(stream, 0L, SEEK_SET);[1]
用 法: void rewind(FILE *stream);
头文件:
stdio.h
返回值:无
A statement such as
rewind( cfptr );
causes a program's file position--which indicates the number of the next byte in the file to be read or written-- to be repositioned to the beginnning of the file pointed to by cfptr.
#include <stdio.h>
#include <dir.h>
int main(void)
{
FILE *fp;
char fname[10] = "TXXXXXX", *newname, first;
newname =
mktemp(fname);
fp = fopen(newname,"w+");
if(NULL==fp)
return 1;
fprintf(fp,"abcdefghijklmnopqrstuvwxyz");
rewind(fp);
fscanf(fp,"%c",&first);
printf("The first character is: %c\n",first);
fclose(fp);
remove(newname);
return 0;
}
中文名rewind含 义函数名功 能指向一个数据流/文件的开头用 法void rewind
目录
1基本内容2英文解释
3程序例
基本内容
编辑函数名: rewind()
功 能: 将文件内部的位置指针重新指向一个流(数据流/文件)的开头
注意:不是文件指针而是文件内部的位置指针,随着对文件的读写文件的位置指针(指向当前读写字节)向后移动。而文件指针是指向整个文件,如果不重新赋值文件指针不会改变。
rewind函数作用等同于 (void)fseek(stream, 0L, SEEK_SET);[1]
用 法: void rewind(FILE *stream);
头文件:
stdio.h
返回值:无
英文解释
编辑A statement such as
rewind( cfptr );
causes a program's file position--which indicates the number of the next byte in the file to be read or written-- to be repositioned to the beginnning of the file pointed to by cfptr.
程序例
编辑#include <stdio.h>
#include <dir.h>
int main(void)
{
FILE *fp;
char fname[10] = "TXXXXXX", *newname, first;
newname =
mktemp(fname);
fp = fopen(newname,"w+");
if(NULL==fp)
return 1;
fprintf(fp,"abcdefghijklmnopqrstuvwxyz");
rewind(fp);
fscanf(fp,"%c",&first);
printf("The first character is: %c\n",first);
fclose(fp);
remove(newname);
return 0;
}
相关文章推荐
- 互联网 免费的WebService接口
- 在Android中使用并发来提高速度和性能
- fsetpos()
- [译]敏捷之殇
- HDU-5563 (Clarke and five-pointed star)
- Html5 js FileReader接口
- pwd命令(转)
- 在Android中使用反射到底有多慢?
- java.lang.ClassNotFoundException: org.apache.commons.pool.impl.GenericObjectPool
- Android性能优化之渲染篇
- Alarmdemo
- accept()
- Android性能优化之运算篇
- Android性能优化之内存篇
- Android性能优化之电量篇
- redis的安装及php的redis使用
- PAT 团体程序设计天梯赛-练习集 L2-003. 月饼
- PHP函数preg_replace() 正则替换所有符合条件的字符串
- IOS开发UI基础学习-------总结
- App安全之网络传输安全