SEEK_CUR
Used in the fseek function to change the file position relative to the current file position.
Syntax
fseek(fileID, 10, SEEK_CUR)
Advance the file position 10 characters forward from the current position.
Example
Example showing SEEK_CUR and related functions:
% example for fseek, ftell, SEEK_END, 'eof', SEEK_SET, 'bof', SEEK_CUR, 'cof'
fileID = fopen('testfile7', 'r')
printf('starting position in file %d\n', ftell(fileID))
% go to end of file and show position
printf('fseek result %d\n', fseek(fileID, 0, SEEK_END)) % can use SEEK_END or 'eof'
printf('after SEEK_END position in file %d\n', ftell(fileID))
% return to beginnin of file and show position
printf('fseek result %d\n', fseek(fileID, 0, SEEK_SET)) % can use SEEK_SET or 'bof'
printf('after SEEK_SET position in file %d\n', ftell(fileID))
% change position +8 characters forward and show position
printf('fseek result %d\n', fseek(fileID, +8, SEEK_CUR)) % can use SEEK_CUR or 'cof'
printf('after SEEK_CUR +8 position in file %d\n', ftell(fileID))
% change position 4 characters backward and show position
printf('fseek result %d\n', fseek(fileID, -4, SEEK_CUR)) % can use SEEK_CUR or 'cof'
printf('after SEEK_CUR -4 position in file %d\n', ftell(fileID))
printf('fclose result %d\n', fclose(fileID))
fileID = 3
starting position in file 0
fseek result 0
after SEEK_END position in file 15
fseek result 0
after SEEK_SET position in file 0
fseek result 0
after SEEK_CUR +8 position in file 8
fseek result 0
after SEEK_CUR -4 position in file 4
fclose result 0