Re:C++里什么汉书可以得到文件长度?

[复制链接]
查看11 | 回复0 | 2021-1-29 02:46:08 | 显示全部楼层 |阅读模式
欧现在sparcsunos上编程,不过我已经找到了,我把原麻贴给大家吧//readafileintomemory#includeiostream#includefstreamusingnamespacestd;
intmain(){intlength;char*buffer;
ifstreamis;is.open(test.txt,ios::binary);
//getlengthoffile:is.seekg(0,ios::end);length=is.tellg();is.seekg(0,ios::beg);
//allocatememory:buffer=newchar[length];
//readdataasablock:is.read(buffer,length);
is.close();
cout.write(buffer,length);
return0;}puppycash (圣堂||八卦派暗黑左使) 在 ta 的帖子中提到:可以用win32的API函数getfilesize用法:includewindows.h在MFC中::getfilesize(hFileHandle)好象还有个参数,记得不是很清楚了。msdn不成,还有google嘛,哪里都可以查的
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行