本文介绍了救命 !如何获得大于2G的文件大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 有一个非常大的文件,我们可以使用stat来获取文件大小(< 2G), struct stat buf ; stat(" file",& buf); long s =(long)stat.st_size; 但是stat :: st_size是off_t的类型(typedef long), 那么大于2G的文件怎么样? 非常感谢〜 there is a file which is very large, we can use stat to get a file size(<2G),struct stat buf;stat("file", &buf);long s=(long)stat.st_size; but stat::st_size is type of off_t(typedef long),so how about a file larger than 2G? many thanks~推荐答案 您必须调查您的平台提供的选项。标准C 本身没有指定获取文件大小的函数。唯一完全 便携式方法是读取文件并保持计数,即便如此, 它的大小在磁盘上。可能与通过阅读 计算的大小不同。 您似乎也在使用C ++。如果是这样,那么适当的组是 comp.lang.c ++。 You''ll have to investigate the options provided by your platform. Standard Citself specifies no functions to get the size of a "file." The only fullyportable method is to read through the file and keep count, and even then,it''s size "on disk" might be different to the size calculated by readingit. You also seem to be using C++. If so, then the appropriate group iscomp.lang.c++. 你在这里和你在clc ++中一样偏离主题,试试comp.unix.programmer。 - Ian Collins。 You are as off topic here as you were in c.l.c++, try comp.unix.programmer. --Ian Collins. stat和off_t不是标准C的一部分,因此在这里偏离主题。 查找处理您系统的新闻组,可能 b $ b comp.unix.programmer。 - Chuck F(cinefalconer at maineline dot net) 可用于咨询/临时嵌入式和系统。 < http://cbfalconer.home.att.net> - 通过 http://www.teranews.com stat and off_t are not part of standard C and thus off-topic here.Find a newsgroup dealing with your system, possiblycomp.unix.programmer. --Chuck F (cbfalconer at maineline dot net)Available for consulting/temporary embedded and systems.<http://cbfalconer.home.att.net> --Posted via a free Usenet account from http://www.teranews.com 这篇关于救命 !如何获得大于2G的文件大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-26 17:28