سؤال

I got a probably small problem using memcmp. I have two arrays (length = 3 byte) with exactly the same data.

If I try to compare them with memcmp, it fails?!

if (memcmp(ucbuffer, ucnewbuffer, buffer.sDeviceData.sLenght)) {
    cout << "val written, val ok!\n";
};

ucbuffer, ucnewbuffer are both unsigned char * and were allocated using

calloc(buffer.sDeviceData.sLenght, sizeof(unsigned char);

If i compare both arrays by hand, both it will result in being exactly the same.

Do you have any Idea?

Have a nice evening.

هل كانت مفيدة؟

المحلول

That function returns zero (i.e., not true) when the buffers compare equal.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top