C/stdio.h/rewind

Материал из C\C++ эксперт
Версия от 10:23, 25 мая 2010; Admin (обсуждение | вклад) (1 версия: Импорт контента...)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

rewind: moves the file position pointer back to the start

    
//Header file:     #include <stdio.h>  
//Declaration:     void rewind(FILE *stream); 
  #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);
  }