Home > Software engineering >  The correct use of MFC programming, the Format function after garbled words what reason be
The correct use of MFC programming, the Format function after garbled words what reason be

Time:09-27

I use vs2015 version, after use the format function, a garbled, now it is not clear what the reason,

This is a "11" transfer came in


Behind after the format, the STR the data is not inside the "11", but gibberish, don't know the reason why

CodePudding user response:

Cstrings coding is unicode, so if you want to use cstrings format, % s must be corresponding value would be * format.
STR. The Format (L "% s \ n", (LPCWSTR) s);

CodePudding user response:

Conversion error.

CodePudding user response:

After receiving the sprintf again

CodePudding user response:

Buf should view using similar to the following function: the content of the
 void HexDump) (char * buf, int len, int addr) {
Int I, j, k;
Char binstr [80].

for (i=0; iIf (0==16) (I %) {
Sprintf (binstr, "% x - 08", I + addr);
Sprintf (binstr, "% s % 02 x", binstr, buf (unsigned char) [I]);
} else if (15==16) (I %) {
Sprintf (binstr, "% s % 02 x", binstr, buf (unsigned char) [I]);
Sprintf (binstr, "% s", binstr);
For (j=I - 15; j<=I; J++) {
Sprintf (binstr, "% s % c," binstr, ('! '}
Printf (" % s \ n ", binstr);
} else {
Sprintf (binstr, "% s % 02 x", binstr, buf (unsigned char) [I]);
}
}
If (0! 16)=(I %) {
16 k=16 - (I %);
for (j=0; jSprintf (binstr, "% s", binstr);
}
Sprintf (binstr, "% s", binstr);
K=16 - k;
For (j=I - k; jSprintf (binstr, "% s % c," binstr, ('! '}
Printf (" % s \ n ", binstr);
}
}

CodePudding user response:

Unicode,
Format, % s must be corresponding would *
Instead of char *
  • Related