OiO.lk Blog C++ Check if uint8_t array contains string
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

Exit mobile version