How do you determine the size of a file in C?

前端 未结 14 960
野性不改
野性不改 2020-11-22 03:20

How can I figure out the size of a file, in bytes?

#include 

unsigned int fsize(char* file){
  //what goes here?
}
14条回答
  •  太阳男子
    2020-11-22 03:58

    A quick search in Google found a method using fseek and ftell and a thread with this question with answers that it can't be done in just C in another way.

    You could use a portability library like NSPR (the library that powers Firefox) or check its implementation (rather hairy).

提交回复
热议问题