C 程序中的库函数,功能是将文件内部的指针重新指向一个流的开头
函数名: rewind(八检关互消受械沿换气)
功 能: 将文件内部的位置指针重新指向一个流(数据流/文件)的开头
注意:不是文件指针而是文件内部的位置指针,随着对文件的读写文件的位置指针(指向当前读写字节)向后移动。而文件指针是指来自向整个文件,如果不重新赋值文件指针不会改变。
rewind函数作用等同于 (void)fseek(strea阳夫晶班m, 0L, SEEK_SET);
用 法: voi360百科d rewind(FILE *stream);
头文件: stdi营轻道单呀冲反直派看怀o.h
返回值:无
右试争促树井 A statement such as
rewind( cfptr );
causes a program's file position--which indi少云过凯响收振cates the number of the next byte in the fi功右输指让凯le to be read or written-- to be repositioned to the beginnni杆止二用能置普米当据ng 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,"a宣欢步济听好换蛋无bcdefghijklmnopqrstuvwxyz");
re烧落要斗造wind(fp);
来自 fscanf(fp,"%c",&first);
printf("The first character is: %c\n",first);
fclose(fp留洋期);
remove(newname);
retu坐清rn 0;
}