Difference between revisions of "FSEEK()"
Helen.george (Talk | contribs) |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Function to position to a byte offset within a text file | Function to position to a byte offset within a text file | ||
− | |||
==Syntax== | ==Syntax== | ||
FSEEK(<expN1>, <expN2>, <expN3>) | FSEEK(<expN1>, <expN2>, <expN3>) | ||
− | |||
==See Also== | ==See Also== | ||
[[FCLOSE()]], [[FCREATE()]], [[FERROR()]], [[FGETS()]], [[FREAD()]], [[FREADSTR()]], [[FWRITE()]] | [[FCLOSE()]], [[FCREATE()]], [[FERROR()]], [[FGETS()]], [[FREAD()]], [[FREADSTR()]], [[FWRITE()]] | ||
− | |||
==Description== | ==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: | 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" | + | |
!Offset||Description | !Offset||Description | ||
|- | |- | ||
Line 25: | Line 21: | ||
|- | |- | ||
|} | |} | ||
− | |||
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. | 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== | ==Example== | ||
Line 37: | Line 31: | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Functions]] | [[Category:Functions]] |
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)