the rewind() function resets the file position indicator to the beginning of the file it takes the file pointer as its arguments.

rewind() function syntax

This program opens a file in write/read mode and takes strings as input using fgets(). The Program rewinds the file and then displays the same strings using fputs().

Rewind() Funtion Program

 { file *fp; char str[30];
 if((fp=fopen ("jak", "w+") ) == NULL )
 { printf("Cannot open file nn");
 } clrscr();
 do{ printf("enter a string");
 if (*str != 'n') { strcat (str, "n");
 fputs(str, fp);
 } } while (*str != 'n');
 printf("nn diplaying content of file jaknn");
 rewind (fp); 
while(!feop(fp)) { fgets (str,81,fp);
 printf("n%s", str);
 } fclose(fp);
This article is written by our awesome writer
Comments to: Rewind() Funtion In C With Example

Your email address will not be published. Required fields are marked *

Attach images - Only PNG, JPG, JPEG and GIF are supported.

New Dark Mode Is Here

Sign In to access the new Dark Mode reading option.

Join our Newsletter

Get our monthly recap with the latest news, articles and resources.

By subscribing you agree to our Privacy Policy.

Latest Articles

Explore Tutorials By Categories


Codeverb is simply an all in one interactive learning portal, we regularly add new topics and keep improving the existing ones, if you have any suggestions, questions, bugs issue or any other queries you can simply reach us via the contact page


Welcome to Codeverb

Ready to learn something new?
Join Codeverb!

Read Smart, Save Time
    Strength indicator
    Log In | Lost Password