Two 2D Arrays Equal?

Hello all,

I’m newbie and wanted to check if two 2D arrays are equal.

To use == doesn’t work.

Do I have to double for loop over them (size is same)?

Thanks!

Swakopmund

I don’t know of any other way. array1 == array2 compares the pointers to the arrays, which could only be true if they are the exact same array, it never checks the actual values.

Depending on the actual use of the array some optimizing may be possible.

what kind of data do you expect? how often do the arrays change, how often do they get compared? Are there many arrays?

It’s all small 7x7 per array, it’s int.
Double for-loop should be fast enough!

Thanks!

That works as well!!

Thanks a lot! :slight_smile: