compare arrays on arduino

Hi guys. I have made a function which compares 2 arrays and tells if they are equal. This is a small portion of a project I am working on. I have written the following code. But it isn't working. On my serial window just Hi is being displayed. Any ideas?

void setup() {
  // put your setup code here, to run once:
 
 
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.print("Hi");
   byte pass1[18]="sim123";
   byte pass2[18]="sim456";
   boolean check ;
  
   check=array_cmp(pass2,pass1,16);
if (check==true) 
{
  Serial.print("It matches");
}
else
{
  Serial.print("No luck"); 
}
while(1);
}

 int array_cmp(byte a[], byte b[], int i)
{
   for(int n=0; n<i; i++)
   {
    if (a[n]!=b[n]){
      return false;
        }
        
   }
   return true;
}

What's wrong with memcmp or strcmp?

 for(int n=0; n<i; i++)

Think that one through again.

Why reinvent the wheel? Try:

void setup() {
  Serial.begin(9600);

  Serial.println("Hi");
  byte pass1[18] = "sim123";
  byte pass2[18] = "sim123";
  int  check ;

  check = memcmp(pass1, pass2, sizeof(pass1));

  if (check == 0)
  {
    Serial.print("It matches");
  }
  else
  {
    Serial.print("No luck");
  }
}

void loop() {
}

econjack:
Why reinvent the wheel? Try:

void setup() {

Serial.begin(9600);

Serial.println("Hi");
  byte pass1[18] = "sim123";
  byte pass2[18] = "sim123";
  int  check ;

check = memcmp(pass1, pass2, sizeof(pass1));

if (check == 0)
  {
    Serial.print("It matches");
  }
  else
  {
    Serial.print("No luck");
  }
}

void loop() {
}

AWOL:
What's wrong with memcmp or strcmp?

 for(int n=0; n<i; i++)

Think that one through again.

I am not using strcmp because it inputs char type data and I am using byte. Also, I think memcmp compares length rather than element by element checking

I am not using strcmp because it inputs char type data and I am using byte.

Just lie to the compiler with a cast.
I won't tell.

I think memcmp compares length rather than element by element checking

You think incorrectly. Check your documentation.

I am not using strcmp because it inputs char type data and I am using byte.

That's one reason I used memcmp() instead. They are not the same.

Most of the simple routines that are needed for all C code, were problems faced by the designers in 1967. That is why they created the standard library. It behooves you to know it, or at least know to look there when it looks like something that might be a common task.

As AWOL said, thisfor(int n=0; n<i; i++)is probably your problem.