The rewind () function in C
The void rewind function (FILE * stream) in Standard C library sets the file location to the beginning of the file in the given stream.
The void rewind function (FILE * stream) in Standard C library sets the file location to the beginning of the file in the given stream .
Declaring rewind () function in C
Below is the declaration for rewind () function in C:
void rewind ( FILE * stream )
Parameters
stream - This is the pointer to a FILE object that identifies the Stream.
Returns the value
This function does not return any values.
For example
The following C program illustrates the use of rewind () function in C:
#include int main () { char str [] = "Hoc C co ban va nang cao tai QTM !!!" ; FILE * fp ; int ch ; /* Dau tien chung ta ghi mot so noi dung vao baitapc.txt */ fp = fopen ( "baitapc.txt" , "w" ); fwrite ( str , 1 , sizeof ( str ) , fp ); fclose ( fp ); fp = fopen ( "baitapc.txt" , "r" ); while ( 1 ) { ch = fgetc ( fp ); if ( feof ( fp ) ) { break ; } printf ( "%c" , ch ); } rewind ( fp ); printf ( "n" ); while ( 1 ) { ch = fgetc ( fp ); if ( feof ( fp ) ) { break ; } printf ( "%c" , ch ); } fclose ( fp ); return ( 0 ); }
Compile and run the above C program to see the results:
According to Tutorialspoint
Previous article: rename () function in C
Next lesson: Function setbuf () in C
4 ★ | 1 Vote
You should read it
Maybe you are interested
How to turn a photo into a painting using the Generative Fill function in Photoshop
How to use the TREND function in Excel
Google Sheets Functions to Simplify Your Budget Spreadsheets
Instructions for using the TRIMRANGE function to clean up Excel tables
How to master numerical data in Google Sheets with the AVERAGE function
Don't buy headphones if they lack this important function!