Everything is a metaphor. What a wonderful world.

0%

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#include <stdlib.h>

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;
}
❤︎ Thanks for ☟ ☟ ☟ your support!