I am working on a project where the function will receive a pointer to a uint8_t array. I am to compare the contents of this with that of a pointer to unsigned char data buffer whose size is not known. I was hoping to use string based functions for the comparison.
Hence the doubt has arisen.
Yes. Consider:
char *str1 = "hello";
uint8_t str2[6] = "hello";
int8_t *str3 = "hello";
int result1 = strcmp(str1, (char*)str2);
int result2 = strcmp(str1, (char*)str3);
Both result1
and result2
are 0
, i.e., all the strings are equivalent.