October 21, 2024
Chicago 12, Melborne City, USA
C++

Check if uint8_t array contains string


In C language I have a uint8_t array and, after some logic, I need to cast to string and check if contains some substring like this:

uint8_t data[8] = {0xcb,0xe2,0x3d,0x96,0x55,0xfc,0xcd,0x43};
    
/// some logic
    
if(strstr((const char *)data, "000") != NULL){
    
}

Is if statement correct? it seems to return always true.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video