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 isCodePudding 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?