Home > Back-end > In C builder how to implement convert hexadecimal string data, such as string is "9 f," co
In C builder how to implement convert hexadecimal string data, such as string is "9 f," co
Time:10-18
In c + + builder how to implement convert hexadecimal string data, such as string is "9 f," convert hexadecimal value is 0 x9f; String is "af", convert hexadecimal value is 0 xaf? The code is as follows:
void __fastcall TForm1: : Button3Click (TObject * Sender) { AnsiString Temp. Char * SendData publishes the event; Int ln. Unsigned long LRC England BS; If (hComm==0) return;//check the Handle value Temp=Memo1 - & gt; The Text;//send the string to convert Temp to hexadecimal SendData=https://bbs.csdn.net/topics/Temp.c_str ();//string //send string data BS=Temp. Length (); //BS=StrLen (SendData publishes the event);//can also use this way get the length of the string //the actual sending action WriteFile (hComm SendData publishes the event, BS, & amp; LRC England, NULL);//actually send data }
CodePudding user response:
SendData=https://bbs.csdn.net/topics/Temp.c_str (); The use of such way is serious is not recommended to use,
String hexadecimal, like this: String STR="9 f"; DWORD dw=StrToInt (" 0 x "+ STR);
CodePudding user response:
Hexadecimal conversion, with the demon elder brother learning, finally took down StrToInt (" 0 x "+ STR);