C/C++多种方法获取文件大小
-
关键字: malloc wxWidgets OpenGL 多态性 doxygen
C/C++多种方法获取文件大小。
C/C++多种方法获取文件大小
#include <iostream>
#include <io.h>
#include <sysstat.h>
#include <afx.h>
#define _AFXDLL
using namespace std;
void main()
{
// 此文件在工程打开状态下为不可访问
char* filepath = "..\test.ncb";
// 方法一
struct _stat info;
_stat(filepath, &info);
int size = info.st_size;
cout<<size<<endl;
// 方法二
FILE* file = fopen(filepath, "rb");
if (file)
{
int size = filelength(fileno(file));
cout<<size<<endl;
fclose(file);
}
// 方法三
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载