#include <stdio.h>
#include <stdlib.h>
long _filesize(FILE *stream)
{
long curpos, length;
curpos = ftell(stream);
fseek(stream, 0L, SEEK_END);
length = ftell(stream);
fseek(stream, curpos, SEEK_SET);
return length;
}
main()
{
FILE *fp;
if ((fp=fopen("C:\\TEMP\\test.jpg", "r")) == NULL)
return;
long buffsize = _filesize(fp);
char *buff = (char *)malloc(buffsize*sizeof(char));
fread(buff, buffsize, 1, fp);
fclose(fp);
int i;
for (i=0; i<10; i++)
//显示前10个字符
printf("%x ", (unsigned char)buff[i]);
free(buff);
}