FAT | RFS | XFS | ZFS

rewind()

PROTOTYPE

#include <stdio.h>

void rewind(FILE *file);

DESCRIPTION

rewind() sets the current position of the open regular file identified by file to its beginning, clears its error and end-of-file indicators, and drops any byte stored on its file control block by ungetc()

rewind(file) is equivalent to fseek(file, 0, SEEK_SET) except the file error indicator is also cleared.

If an error occurs, errno is set to a positive value.

ERROR CODES

EBADF file is not the handle of an open file.
EISDIR The specified file is a directory.

EXAMPLE

    /*-----------------------------------------------------------------*/
    /* Clear buffer and reset file position.                           */
    /*-----------------------------------------------------------------*/
    bzero(buf, buf_sz);
    rewind(file);