rewind : rewind « stdio.h « C Tutorial






ItemValue
Header filestdio.h
Declarationvoid rewind(FILE *stream);
Functionmoves the file position pointer back to the start.


#include <stdio.h>
  #include <stdlib.h>

  int main(int argc, char *argv[])
  {
    FILE *fp;

    if((fp=fopen("test", "r"))==NULL) {
      printf("Cannot open file.\n");
      exit(1);
    }

    while(!feof(fp)){
        putchar(getc(fp));
    }
    rewind(fp);


    while(!feof(fp)){
        putchar(getc(fp));
    }
    fclose(fp);
  }








22.30.rewind
22.30.1.rewind