70,021
社区成员




#include <stdio.h>
#include <string.h>
int main() {
unsigned char s[24]={
0xAA,0xAA,0x04,0x80,0x02,0x12,0x34,0x99,
0xAA,0xAA,0x04,0x80,0x02,0x56,0x78,0x99,
0xAA,0xAA,0x04,0x80,0x02,0x12,0x34,0x99,
};
unsigned char m[5]={0xAA,0xAA,0x04,0x80,0x02};
unsigned char d[6];
unsigned char *ps,*pd;
ps=s;
pd=d;
while (1) {
if (0==memcmp(ps,m,5)) {
pd[0]=ps[5];
pd[1]=ps[6];
ps+=8;
pd+=2;
if (ps-s>=24 || pd-d>=6) break;
} else break;
}
for (int i=0;i<6;i++) printf("0x%02X ",d[i]);
return 0;
}
//0x12 0x34 0x56 0x78 0x12 0x34