64,647
社区成员
发帖
与我相关
我的任务
分享
看
#include "stdlib.h"
#include "stdio.h"
int main()
{
FILE* fpFile = fopen("test.txt", "rb");
if (!fpFile)
return 1;
unsigned char* bytebuff = 0;
fseek(fpFile, 0, SEEK_END);
int file_len = ftell(fpFile);
fseek(fpFile, 0, SEEK_SET);
bytebuff = new unsigned char[file_len];
fread(bytebuff, file_len, 1, fpFile);
for (int i = 0; i < file_len; ++i) {
unsigned long dw = (unsigned long)bytebuff[i];
if (!(i % 10) && i != 0)
printf("\n");
printf("%02X ", dw);
}
delete bytebuff;
fclose(fpFile);
return 0;
}