Arrays Vergleichen

Hallo,
ich möchte zwei Arrays vergleichen und wenn dort unterschiede Vorkommen mir den Unterschied ausgeben lassen. Ist das möglich?

viele Grüße

Cicada§§=!

Hello,
I would like to compare two arrays and if there are differences, I want to occur the difference to me. Is that possible?

Best regards

Cicada§§ =!

Show what you have tried.

The basics is to loop through the arrays using a single loop

for (int cnt = 0; cnt < sizeof(yourArray1) && cnt < sizeof(yourArray2); cnt++)
{
  //if(yourArray1[cnt]!=yourArray1[cnt])
  if(yourArray1[cnt]!=yourArray2[cnt])
  {
    Serial.println("mismatch");
  }
}

Thank you

Thats what I needed

Best Regards

Cicada §§=!

You could also use memcmp(). If it returns non-zero, you could then look for the element that doesn't match.

if(yourArray1[cnt]!=yourArray1[cnt])I don't think you meant quite that...

econjack:
You could also use memcmp(). If it returns non-zero, you could then look for the element that doesn't match.

Problem is the 'reporting' of mismatches.

UKHeliBob:
if(yourArray1[cnt]!=yourArray1[cnt])I don't think you meant quite that...

I was sure I fixed that before posting; obviously not :wink: Thanks, will fix it