Table of Contents

rewind

Description

Rewind a file handle to the start of the file stream.

Function prototype

void rewind <voidptr:hFile>

Arguments

Name Type Comment
hFile voidptr A file handle, as created by fopen or fopen_s.

Return value

None.

Example

// open a file, fseek forward, then rewind

// open file
voidptr fp
assert <zs:fopen_s fp "C:\\test.txt" "r"> "Could not open file!"

// fseek to 10
assert <zs:fseek fp 10 0> "Fseek failed!"
echo <zs:ftell fp> // should be at 10 now

// rewind
rewind fp
echo <zs:ftell fp> // should be back at 0

// close
fclose fp

… the output of which is written to the event log by echo as:

10
0

Comments

This function is equivalent to calling 'fseek 0 0'.

See also