How to Get the Length of File in C

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了How to Get the Length of File in C相关的知识,希望对你有一定的参考价值。

How to get length of file in C

//===
int fileLen(FILE *fp)
{
    int nRet = -1;
    int nPosBak;

    nPosBak = ftell(fp);///< current position in file

    fseek(fp, 0, SEEK_END);
    nRet = ftell(fp);

    fseek(fp, nPosBak, SEEK_SET);///< write back position to file
    return nRet;
}

以上是关于How to Get the Length of File in C的主要内容,如果未能解决你的问题,请参考以下文章