C++ memcmp fails with unsigned char array?

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.

Answers


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


Need Your Help

UITextView large text in UIAlertView

iphone objective-c ios ios4

I have an UIAlertView with UITextView.

MVVM Light DataGrid DeleteCommand

c# wpf mvvm wpfdatagrid mvvm-light

short structure of my project is (using MVVM Light Toolkit):