#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
FILE *fp = NULL;
int i = 0;
typedef <#type#> <#name#>;
fp = fopen(argv[1], "r");
if (fp == NULL) {
perror("fopen");
exit(1);
}
//通过fseek将文件内容指针移动到文件尾部
fseek(fp, 0, SEEK_END);
//通过ftell来返回文件最后内容的位置,来得知文件有多少字符
printf("%ld\n", ftell(fp));
//关闭文件
fclose(fp);
exit(0);
}
通过ftell获取文件长度
最新推荐文章于 2025-04-13 10:05:21 发布