File operation: fseek ()

Source: Internet
Author: User

int fseek (FILE *stream, long offset, int fromwhere);

fseek is used to open files in binary mode, move file read/write pointer position.
 int fseek (FILE *stream, long offset, int origin);the first parameter stream is a file pointer
The second parameter offset is the offset, the integer represents the forward offset, and the negative number represents the negative offset
The third parameter, origin, sets the offset from where the file begins, possibly with a value of: Seek_cur, Seek_end, or Seek_set
seek_set: File Start
seek_cur: Current Location
seek_end: End of File
where Seek_set,seek_cur and Seek_end and sequentially 0, 1 and 2.
 In short:
fseek (fp,100l,0); Move the fp pointer to 100 bytes from the beginning of the file;
fseek (fp,100l,1); Move the fp pointer to 100 bytes from the current position of the file;
fseek (fp,100l,2); Returns the fp pointer to 100 bytes from the end of the file.

File operation: fseek ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.