Relationship between the return value and pointer position of the fseek file offset position

Source: Internet
Author: User

Relationship between the return value and pointer position of the fseek file offset position

The pointer offset of the corresponding file is not clearly described in the function definition. When the offset is a positive number, it is offset to the end of the file, when it is a negative number, it is offset to the file header. Here, we need to pay attention to the relationship between the offset size and the file size boundary.

When offset is an offset to the end of a file, fseek returns 0 regardless of whether the offset exceeded the end of the file. When the offset does not exceed the end of the file, the file Pointer Points to the normal offset address. When the offset exceeds the end of the file, the file Pointer Points to the end of the file. The offset error-1 value is not returned.

When offset is offset to the file header, if the offset does not exceed the file header, it is normal offset. The file Pointer Points to the correct offset address, and the return value of fseek is 0. when the offset value exceeds the file header, fseek returns the error-1 value, and the file pointer remains unchanged at the original address.

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.