<< fscanf | Stream manager | fsize >> |
fseek(fid, offset, origin) |
status = fseek(fid, offset, origin) |
an integer value: file descriptor
an integer value: number of bytes to move from origin.
an integer value or a string: location in the file.
an integer value: 0 or -1 if there is an error.
fseek moves the file pointer to the location offset within the file fid.
origin can take as value:
'bof' or -1 : beginning of file.
'cof' or 0 : current position in file.
'eof' or 1 : end of file.
offset may be one of the predefined variables SEEK_CUR (current position, or 0), SEEK_SET (beginning, or -1), or SEEK_END (end of file, or 1).
fileID = fopen([tempdir(), 'fseek.txt'],'wt');
fprintf(fileID, 'son is beautiful.');
fseek(fileID, SEEK_CUR, 'bof');
fprintf(fileID, 'sun');
fclose(fileID);
R = fileread([tempdir(), 'fseek.txt'])
Version | Description |
---|---|
1.0.0 | initial version |
Allan CORNET