在C程序文件的大小

在C程序文件的大小

问题描述:

我只是想找到的Çprogram..I写了code中的帮助文件的大小,但它给错误的结果...

I just want to find the file size with the help of c program..I wrote a code but it give wrong result...

fseek(fp,0,SEEK_END);
osize=ftell(fp);

有没有别的办法?

Is there any other way?

FTELL返回一个int。如果你是一个系统,int是32位,并且您的文件超过2GB,你很可能有负面的大小结束。 POSIX ftello提供和fseeko它们使用off_t。 C有fgetpos和fsetpos它们使用fpos_t - 但fpos_t不是一个算术类型 - 它的语言环境,例如保持相关的字符集的处理事情

ftell returns an int. If you are on a system where int is 32 bits and your file is more than 2GB, you may very well end up with a negative size. POSIX provides ftello and fseeko which use a off_t. C has fgetpos and fsetpos which use a fpos_t -- but fpos_t is not an arithmetic type -- it keeps things related to the handling of charset by the locale for instance.