Difference between revisions of "FSEEK()"
Helen.george (Talk | contribs) |
Helen.george (Talk | contribs) |
||
Line 11: | Line 11: | ||
The FSEEK() function is used to position to a byte offset within a text file. The <expN1> is a valid file handle returned from the FOPEN() function. The <expN2> is the byte offset position to move the file pointer based on value defined by <expN3>. This can be a positive or negative number depending on the direction of pointer movement. The <expN3> defines the positions from which to start the byte offset, and can be any of the following three options: | The FSEEK() function is used to position to a byte offset within a text file. The <expN1> is a valid file handle returned from the FOPEN() function. The <expN2> is the byte offset position to move the file pointer based on value defined by <expN3>. This can be a positive or negative number depending on the direction of pointer movement. The <expN3> defines the positions from which to start the byte offset, and can be any of the following three options: | ||
− | {| class="wikitable" width=100% | + | {| class="wikitable" width="100%" |
!Offset||Description | !Offset||Description | ||
|- | |- |
Latest revision as of 12:25, 1 February 2013
Contents
Purpose
Function to position to a byte offset within a text file
Syntax
FSEEK(<expN1>, <expN2>, <expN3>)
See Also
FCLOSE(), FCREATE(), FERROR(), FGETS(), FREAD(), FREADSTR(), FWRITE()
Description
The FSEEK() function is used to position to a byte offset within a text file. The <expN1> is a valid file handle returned from the FOPEN() function. The <expN2> is the byte offset position to move the file pointer based on value defined by <expN3>. This can be a positive or negative number depending on the direction of pointer movement. The <expN3> defines the positions from which to start the byte offset, and can be any of the following three options:
Offset | Description |
---|---|
0 | Start from start of file |
1 | Start from current position |
2 | Start from EOF |
FSEEK() returns the new position of the file pointer relative to the beginning of the file. The beginning of the file is 0 regardless of the direction of movement.
Example
fp = fopen("names.txt") string = fgets(fp) fseek(fp, 1024,0)