C語言常用函數-filelength()文件字節數統計函數


演示版本

VS2012

  • filelength()函數

filelength()函數用於統計由open()所打開文件的字節數。

語法

int filelength(int handle);

filelength()函數的語法參數說明如下:

參數handle為要統計的文件句柄。

filelength()函數返回打開文件的長度。

示例

#include <io.h>
#include <fcntl.h>
#include <stdio.h>

int main()
{
    int file;
    long length;
    FILE *fp;
    fp = fopen("d:\\1\\1\\1.txt", "r");
    file = _dup(_fileno(fp));
    length = _filelength(file);
    printf("%ld\n", length);
    fclose(fp);
}

 

阿飛

2021年8月3日


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM