Here is a small C code to highlight an issue on memcmp return value:
char *str1 = "\200";
char *str2 = "\0";
int val1 = memcmp(str1, str2, 2);
int val2 = memcmp("\200", "\0", 2);
printf("val 1 : %d \n",val1);
printf("val 0 : %d \n",val2);
Stdout is:
val 1 : 128
val 2 : -1
Is there an explication for the difference between the 2 functions call? Thanks for your help.
the clang version:
Apple LLVM version 9.0.0 (clang-900.0.39.2) Target: x86_64-apple-darwin16.7.0