c/c++ 读取图片容量大小

// qidong.cpp : Defines the entry point for the console application.
//


#include "stdafx.h"
#include<stdio.h>
#include<stdlib.h>
#include<Windows.h>
#include<math.h>


int _tmain(int argc, _TCHAR* argv[])
{
FILE *fp;
long siz;
char path[100]="E://1.jpg";   //图片地址,我的图片放在E盘根目录

if((fp=fopen(path,"rb"))==NULL)

printf("不能打开该地址文件,请检查\n");
getchar();
return 0;
}
if (fp) {
      fseek(fp, 0, SEEK_END);
      siz = ftell(fp);
      fclose(fp);
   }
siz/=1024.0;
printf("该图片大小为 %ld kb\n",siz);
getchar();
return 0;

}

使用VS2010编译,代码正确,并且结果也正确,写下来给大家参考,希望能帮到你!




你可能感兴趣的:(C++,c,图片,VS2010,容量大小)