You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
memcmp compare stream of bytes, not arrays of other bigger types like uint16_t, uint32_t or uint64_t. You can still use it with those types, but you need to properly calculate the number of bytes to compare For example:
constsize_tlen=4;
uint32_ta[len] = {0, 1, 2, 3};
uint32_tb[len] = {0, 10, 20, 30};
// WRONG: will output "Arrays are equal"if (memcmp(a, b, len) ==0) {
printf("Arrays are equal\n");
} else {
printf("Arrays are different\n");
}
// CORRECT: will output "Arrays are different"if (memcmp(a, b, len*sizeof(uint32_t)) ==0) {
printf("Arrays are equal\n");
} else {
printf("Arrays are different\n");
}
There are a couple of places where memcmp is being used incorrectly:
tests/gov2.c
tests/timestamps.c
The text was updated successfully, but these errors were encountered:
memcmp
compare stream of bytes, not arrays of other bigger types like uint16_t, uint32_t or uint64_t. You can still use it with those types, but you need to properly calculate the number of bytes to compare For example:There are a couple of places where
memcmp
is being used incorrectly:tests/gov2.c
tests/timestamps.c
The text was updated successfully, but these errors were encountered: