Menu
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY CYBERSECURITY DATA SCIENCE
     ❯   

C stdio rewind() Function

❮ C stdio Library


Example

Use the rewind() function to read the beginning of the file twice:

FILE *fptr;
fptr = fopen("filename.txt", "r");

char myString[100];

fgets(myString, 100, fptr);
printf("%s", myString);

rewind(fptr);

fgets(myString, 100, fptr);
printf("%s", myString);

fclose(fptr);

Definition and Usage

The rewind() function moves the position indicator to the beginning of the file.

The rewind() function is defined in the <stdio.h> header file.


Syntax

rewind(FILE * fptr);

Parameter Values

Parameter Description
fptr Required. A file pointer, usually created by the fopen() function.

❮ C stdio Library