Read 16 credit string functions: Strtol
_CRTIMP long __cdecl strtol (const char *, char **, int); // stdlib.h
Void HexStobinary (byte * data, int buf_len, const char * hEX_STR)
{
Char * Phex = (char *) HEX_STR;
BYTE * PBUF = DATA;
INT LEN = 0;
While (Phex && Phex [0] && Phex [1] && (Len { * PBUF = (char) strtol (Phex, & Phex, 16); } * PBUF = '/ 0'; } Void binarytohexstr (char * hEX_STR, Const Byte * Data, INT LEN) { Char * Phex = (char *) HEX_STR; Const byte * pdata = data; For (int i = 0; i { Sprintf (Phex, "% 02X", (Byte) (* pdata)); PDATA ; PHEX = 3; } * PHEX = '/ 0'; } The above method is suitable for reading a large string 16 credit string data from a file. If the number is small and known, it can be converted: The above method is suitable for reading a large string 16 credit string data from a file. If the number is small and known, it can be converted: char * pstr = "5E 34 7A "; Int N [3] = {0}; SSCANF (PSTR,"% x% x% x ", & n [0], & n [1], & n [2]); _CRTIMP long __cdecl strtol (const char *, char **, int); // stdlib.h Void HexStobinary (byte * data, int buf_len, const char * hEX_STR) { Char * Phex = (char *) HEX_STR; BYTE * PBUF = DATA; INT LEN = 0; While (Phex && Phex [0] && Phex [1] && (Len { * PBUF = (char) strtol (Phex, & Phex, 16); } * PBUF = '/ 0'; } Void binarytohexstr (char * hEX_STR, Const Byte * Data, INT LEN) { Char * Phex = (char *) HEX_STR; Const byte * pdata = data; For (int i = 0; i { Sprintf (Phex, "% 02X", (Byte) (* pdata)); PDATA ; PHEX = 3; } * PHEX = '/ 0'; } The above method is suitable for reading a large string 16 credit string data from a file. If the number is small and known, it can be converted: char * pstr = "5E 34 7A " INT N [3] = {0}; SSCANF (PSTR, "% x% x% x", & n [0], & n [1], & n [2]);