You should certainly try doing it using memcmp()
, but if that creates overhead you can do it like @LS_dev suggested, although I would suggest doing explicit character accesses to avoid the endianness issue:
if(((unsigned char *) data)[0] == 0xff && ((unsigned char *) data)[1] == 0x3b)
{
}
of course, it would make sense to factor out the casting for a major clarity boost:
const unsigned char *chardata = data;
if(chardata[0] == 0xff && chardata[1] == 0x3b)
{
}