两种方法:
1、用stat()函数来获取
int main()
{
struct stat st ;
stat( "file.txt", &st );
printf(" file size = %d\n", st.st_size);
return 0;
}
2、用ftell()函数来获取
int main()
{
FILE *fp;
fp=fopen( "file.txt", "r");
fseek(fp, 0L, SEEK_END );
printf(" file size = %d\n", ftell(fp) );
return 0;
}
温馨提示:答案为网友推荐,仅供参考