-
rewind
(C程序中的庫函數)
鎖定
- 中文名
- rewind
- 含 義
- 函數名
- 功 能
- 指向一個數據流/文件的開頭
- 用 法
- void rewind
rewind基本內容
函數名: rewind()
功 能: 將文件內部的位置指針重新指向一個流(數據流/文件)的開頭
注意:不是文件指針而是文件內部的位置指針,隨着對文件的讀寫文件的位置指針(指向當前讀寫字節)向後移動。而文件指針是指向整個文件,如果不重新賦值文件指針不會改變。
rewind函數作用等同於 (void)fseek(stream, 0L, SEEK_SET);
[1]
用 法: void rewind(FILE *stream);
頭文件: stdio.h
返回值:無
rewind英文解釋
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.
rewind程序例
#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; }