Home > Software engineering >  MFC send TXT file data for help
MFC send TXT file data for help

Time:10-11

Using vc6.0, from local TXT read data such as "1512 D1 16", have the functions by cstrings read TXT, and archived in the vector, and will send a delete a vector, the effect of want to achieve is to "1512 16 D1" according to the 15 December 16 D1 to send, the problems are the result of sending is 5 1 2 1 6 D 1 these corresponding ASCII characters, such as 1 into 31, etc., is a great god, and how to realize the function, sample code, forget is a great god glad to everyone

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 1

CodePudding 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 method

CodePudding 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 35
31 and 32 such values, in the hope that the effect of sending 12 such hair is 15, then reads to verify 15 12 such
  • Related