zoukankan      html  css  js  c++  java
  • linux c 语言之--fseek(),fseeko(),fseeko64()讲解 (转载)

    转载:http://blog.csdn.net/lemoncyb/article/details/16841317


    fseek() 函数讲解:
    函数定义:

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

    int fseeko(FILE *stream, off_t offset, int fromwhere);

    int fseeko64(FILE *stream, off64_t offset, int fromwhere);


    参数:

    stream:文件指针

    fromwhere:偏移起始位置

    offset:偏移量


    功能:

    函数设置文件指针stream的位置。如果执行成功,stream将指向以fromwhere(偏移起始位置:文件头0(SEEK_SET),当前位置1(SEEK_CUR),文件尾2(SEEK_END))为基准,偏移offset(指针偏移量)个字节的位置。如果执行失败(比如offset超过文件自身大小),则不改变stream指向的位置。

    说明:这几个函数唯一的不同是offset的数据类型不同,相应的能够处理的偏移量的范围也就有大有小。


    返回值:

    成功,返回0,失败返回-1,并设置errno的值,可以用perror()函数输出错误。
    fseek position the file(文件) position(位置) pointer(指针) for the file referenced by stream to the byte location calculated by offset.

  • 相关阅读:
    Common Element in Two Sorted Sets
    Nearest Points on a Plane
    Influencer Finder
    Range of Intervals
    *Common characters
    自定义栈 和装箱,拆箱
    1.Vector(同步)和ArrayList(异步)异同
    STL中的迭代器的使用
    如何优化limit?
    mysql五大引擎之间的区别和优劣之分
  • 原文地址:https://www.cnblogs.com/JsonZhangAA/p/9674967.html
Copyright © 2011-2022 走看看