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.
Table of Contents
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
Read More
- How to fast forward and rewind 10 seconds in YouTube
- The most popular iPhone apps
- Save time with these text formatting functions in Microsoft Excel
- Function in programming C
- DAY function in SQL Server
- MIN function in SQL Server
- MAX function in SQL Server
- SUM function in SQL Server
- The ord () function in Python
- RIGHT function in SQL Server
- Int () function in Python
- AVG function in SQL Server
- 6 Conditional Functions That Make Excel Spreadsheets Smarter
- Hex () function in Python