1 rewind(FILE *stream);
1
2
3 int main(){
4
5 FILE *file;
6 char data[60];
7 file = fopen ("text.txt","w+");
8 fputs("Setting current location of the cursor using fseek function !", file);
9 fflush(file);
10
11 // set cursor to 30th character in the file
12 fseek(file, 30, SEEK_SET);
13 fflush(file);
14 fgets ( data, 60, file );
15 printf("\nAfter SEEK_SET to 30 : %s", data);
16
17 // set cursor at beginning of the file
18 rewind(file);
19 fgets ( data, 60, file );
20 printf("\nAfter rewind() : %s", data);
21
22 fclose(file);
23 return 0;
24 }
1 After SEEK_SET to 30 : e cursor using fseek function !
2 // after rewind function called.
3 After rewind() : Setting current location of the cursor using fseek function