Rewind() Funtion In C With Example

the rewind() function resets the file position indicator to the beginning of the file it takes the file pointer as its arguments.
rewind() funtion syntax
we are create this program opens a file in write/read mode takes strings as input using fgets(), rewind the file and then displays the same strings using fputs().

what is Rewind() Funtion In C With Example

#inclue<stdio.h> main() { file *fp; char str[30]; if((fp=fopen ("jak", "w+") ) == NULL ) { printf("Cannot open file \n\n"); } clrscr(); do{ printf("enter a string"); gets(str); if (*str != '\n') { strcat (str, "\n"); fputs(str, fp); } } while (*str != '\n'); printf("\n\n diplaying content of file jak\n\n"); rewind (fp); while(!feop(fp)) { fgets (str,81,fp); printf("\n%s", str); } fclose(fp); }