Home > Back-end >  MFC read. Bin file
MFC read. Bin file

Time:09-22

MFC read. Bin file, read out data appear problem, the original data such as "24 38 E0 44 02 C9 28 90 01 F0 22 02 91 78 FFFFFF9C 53", but is now come out of data thus "02 FFFFFFC9 28 FFFFFF90 24 38 FFFFFFE0 44 01 FFFFFFF0 22 02 FFFFFF91 FFFFFF9C 78 53", strives for the great god help!
Long Filelen;
Char * a_pData;
The FILE * fp.
If (fp=fopen (STR, "r"))//STR is mine. Bin file path
{
Fseek (fp, 0, SEEK_END);
Filelen=ftell (fp);
//allocate memory
A_pData=https://bbs.csdn.net/topics/(char *) malloc (Filelen);
//read the file to the allocated memory
Fseek (fp, 0, SEEK_SET);
Fread (a_pData, 1, Filelen, fp);
fclose(fp);

Cstrings sResult;
for(int i=0; i {
Cstrings s="";
S. ormat (" % 2 "x, a_pData [I]);//add a space behind, to separate each byte, we can see more clearly
SResult +=s;//sResult is the hexadecimal string
}
}

CodePudding user response:

When the original data "02 C9 28 90 24 38 E0 44 01 F0 22 02 91 c 78 53"

CodePudding user response:

Problem has been resolved, change char to UCHAR is

CodePudding user response:

If (fp=fopen (STR, "rb"))

CodePudding user response:

Why I use this code to read some bin file is read and application UltraEdit is same, why some bin file read is different, followed by a lot of CD, what happened?
  • Related