unsigned char sim_ioA[] =
" 0xA5 0x12 0x00 0xFF 0x0B 0x60 0x02 0x22 0x09 0x00 ";
unsigned char sim_ioB[10] =
{ 0xA5,0x12,0x00,0xFF,0x0B,0x60,0x02,0x22,0x09,0x00 };
要求把上面的sim_ioA变成下面的格式在线等
这个嘛。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
没人能解决吗 我是醉了
c++方案
void func()
{
CEdit *pBoxOne;
pBoxOne = (CEdit* )GetDlgItem(IDC_EDIT_TPOND);
GetDlgItem(IDC_EDIT_TPOND)->GetWindowText(str); //从edi控件中获取的数据放在STR中
//MessageBox(str);
int Len = 0;
int i = 0;
unsigned int y[1024] = {0};
unsigned char packet[256];
memset(packet,0x00,256);
Len = str.GetLength();
// "A5 12 00 FF 0B 60 02 22 09 00"
SetDlgItemInt(IDC_EDIT_AUTO_TIMER,Len);
for(int i = 0; i< strlen(str); i++)
{
str.Replace(_T(" "),_T(""));
Ti = str.Mid(i,1);
y[i] = strtol((LPSTR)(LPCTSTR)Ti, NULL, 16);
}
for(int i = 0; i<(strlen(str))/2; i++)
{
packet[i] = (BYTE)(y[i*2]*16 + y[i*2+1]);
if(packet[i] == 0)
{
packet [i] = 0x00;
}
}
memcpy(Sendtemp,packet, 10);
}
c 语言方案
void func()
{
int i =0;
char *s1 = NULL;
int tmp;
while(1)
{
s1 = strstr(soure, _T("0x"));
if(s1 == NULL)
{
break;
}
s1+=2;
if(*s1 >= '0'&& *s1<='9')
{
str[i] = ((*s1) - '0') *16;
}
else if(*s1>= 'A' && *s1 <= 'F')
{
str[i] = ((*s1) - 'A' +10)*16;
}
if(*(s1 +1) >= '0'&& *(s1+1)<='9')
{
tmp = (*(s1 + 1) - '0');
str[i] += tmp;
}
else if(*(s1 +1) >= 'A'&& *(s1+1)<='Z')
{
str[i] += (*(s1 + 1) - 'A' + 10);
}
i++;
soure = s1;
}
}