VC++中,如何在返回的指令中提取出16进制的数据,并把它在另一个编辑框中以10进制输出?跪求!急急急!

2025-04-15 09:00:40
推荐回答(2个)
回答1:

strContent=m_strDataReceived.Right(21);
stre= strContent.Left(5);
char* p = (char*)(LPCTSTR)stre;
char buf[3];
buf[0]=p[0]; buf[1]=p[1];buf[2]=p[3]; buf[3]=p[4];
float f=hextodec(buf);
char temp1[10];
sprintf(temp1,"%f",f);
str1 = temp1;
m_dian1=f/2000;

回答2:

int nResult = (int) ( ( buf[0] << 4 ) | buf[1] );