Home » rewind() in C

C rewind() function

The rewind() function sets the file pointer at the beginning of the stream. It is useful if you have to use stream many times.

Syntax:

Example:

File: file.txt

File: rewind.c

Output:

this is a simple textthis is a simple text 

As you can see, rewind() function moves the file pointer at beginning of the file that is why “this is simple text” is printed 2 times. If you don’t call rewind() function, “this is simple text” will be printed only once.

Next TopicC ftell() function

You may also like