C语言常用函数-filelength()文件字节数统计函数

2021/8/3 23:08:29

本文主要是介绍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日



这篇关于C语言常用函数-filelength()文件字节数统计函数的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程