C语言学习笔记之获取文件长度

本文为原创文章,转载请标明出处

#include 
#include 

int main() {
    FILE *inputFile;
    inputFile = fopen("data.bin", "rb");
    if (!inputFile) {
        fprintf(stderr, "Can't open bin file!");
        exit(1);
    }

    fseek(inputFile, 0, SEEK_END);
    long inputFileLength = ftell(inputFile);
    printf("input file length: %ld\n", inputFileLength);
    fseek(inputFile, 0, SEEK_SET);

    fclose(inputFile);
    return 0;
}

你可能感兴趣的:(C语言学习笔记之获取文件长度)