CodePudding user response:
You this is not right? Reading is 31 char '1' is not yao write read according to the char into TXT file is not 1CodePudding user response:
What is your definition of vector type?CodePudding user response:
Fyi:# include & lt; stdio.h>
#include
#include
The FILE * fi * fo;
int r;
Unsigned int n, c;
Long offset.
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Void main (int arg c, char * argv [])
{
If (argc<3) {
Cprintf (" Hex2Bin srcfile desfile ");
return;
}
If ((fi=fopen (argv [1], "rb"))==NULL) {
Cprintf (" Can not find the file % s ", argv [1]).
return;
}
If ((fo=fopen (argv [2], "wb"))==NULL) {
The fclose (fi);
Cprintf (" Can not create the file % s ", argv [2]).
return;
}
n=0;
While (1) {
Offset=ftell (fi);
R=fscanf (fi, "% 2 x", & amp; C);
If (EOF==r) break;//
If (1==r) {
Fputc (c, fo);
n++;
} else {//0==r
Fseek (fi, offset, SEEK_SET);//for VC6 Release version and the VC7, 8,9,10,... Version of the fscanf not offset unchanged by the agreement, so I must restore offset
R=fgetc (fi);
If (EOF==r) break;//
}
}
Fcloseall ();
Cprintf (" OK to Hex2Bin % d bytes. The ", n);
}
CodePudding user response:
By strtol methodCodePudding user response:
Vector is a BYTE type, and then sent into CBytearray, the problem is the vector of each element is 1 5 1 2 one by one, then sent to the board and then read it out is 31 to 3531 and 32 such values, in the hope that the effect of sending 12 such hair is 15, then reads to verify 15 12 such