frewind

Moves the file pointer to the beginning of the file fileID. Returns 0 on success.

Syntax

frewind(fileID)

Inputs

fileID
File ID returned by fopen().
Type: char | string

Outputs

R
Returns 0 on success and -1 on failure.

Example

Simple frewind example shows the ftell() functions file position before and after a frewind call.
[fopen_fileID, fopen_msg] = fopen('testfile', 'r')
while feof(fopen_fileID) == false
	[fgets_return, fgets_length] = fgets(fopen_fileID)
	ftell_return = ftell(fopen_fileID)
end
printf('ftell position before frewind %d\n', ftell(fopen_fileID));
frewind(fopen_fileID)
printf('ftell position after  frewind %d\n', ftell(fopen_fileID));
printf('return from fclose %d', fclose(fopen_fileID));
fopen_fileID = 6
fopen_msg = 
fgets_return = testoutput

fgets_length = 12
ftell_return = 12
ftell position before frewind 12
ftell position after  frewind 0
return from fclose 0