我应该使用fseek的SEEK_END [英] should I use fseek SEEK_END

查看:222
本文介绍了我应该使用fseek的SEEK_END的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题很简单:

我应该使用fseek的与SEEK_END去一个文件的末尾,然后获得它的长度是多少?
因为在男人应该这样说:

Should I use fseek with SEEK_END to get to the end of a file and then get the length of it ? Because in the man it is said:


      
  • 库允许实现(使用它没有真正的标准便携因此,code)不支持有意义SEEK_END。

  •   

现在我使用的统计(来自C)哪个好?

Right now I am using stat (from C) which is better ?

推荐答案

FTELL 函数返回一个长,这意味着一个ILP32系统上则无法获得正确文件的大小超过2GB。您应该使用与stat 函数或类似的获取文件的大小;检查你在你使用一个不同的函数名(stat64中)的情况下针对操作系统手册或定义一个preprocessor宏来获取大文件所需的行为。

The ftell function returns a long, which means that on an ILP32 system you can't correctly get the size of a file larger than 2GB. You should use the stat function or similar to get the size of a file; check the manual for the operating system you're targeting in case you have use a different function name (stat64) or define a preprocessor macro to get the desired behavior for large files.

这篇关于我应该使用fseek的SEEK_END的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆