rewind()
#include <stdio.h>
#include <conio.h>
void main() {
FILE *fp;
char c;
clrscr();
fp = fopen("file.txt", "r");
while( (c = fgetc(fp) ) != EOF) {
printf("%c", c);
}
rewind(fp); // move the file pointer to the beginning of the file
while( (c = fgetc(fp) ) != EOF) {
printf("%c", c);
}
fclose(fp);
getch();
}
// output
// Hello World! Hello World!
Comments