Posted on 03-06-2009
Filed Under (技术) by waterlin

在C++里读出文件大小的方法,示例代码如下:

#include <iostream>
#include <fstream>
using namespace std;

int main () {
long begin,end;
ifstream myfile (“example.txt”);
begin = myfile.tellg();
myfile.seekg(0, ios::end);
end = myfile.tellg();
myfile.close();
cout << “size is: ” << (end-begin) << ” bytes.\n”;
return 0;
}

© 2009, 浏忙大爆炸. All rights reserved.
除非注明,浏忙大爆炸文章均为原创,转载请以链接形式标明本文地址。

(0) Comments    (555) Views    Read More   
Post a Comment
Name:
Email:
Website:
Comments: