现在的位置: 首页 > 综合 > 正文

C++如何获得文件大小(1)

2013年08月24日 ⁄ 综合 ⁄ 共 317字 ⁄ 字号 评论关闭
对文件操作时有时获得文件的大小时必要的.
下面是获得其大小小的较简单方法.
#include<io.h>   //C语言头文件
#include<iostream>   //for system();
using namespace std;
int main()
{
  int handle;
  handle = open("test.txt", 0x0100); //open file for read
  long length = filelength(handle); //get length of file
  cout<<"file length in bytes:"<<length<<endl;
  close(handle);
 
  system("pause");
  return 0;
}

抱歉!评论已关闭.