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
Difference between function and formula in Excel
8 little-known Excel functions that can save you a lot of work
How to use the NORMDIST function in Excel - Function that returns the distribution in Excel
Date functions in Excel, DAY, WEEKDAY, MONTH
How to use the SUMIF function in Excel to calculate the sum based on conditions
How to use the Round function in Excel to round numbers and process data