Struggling to Count Arrays with "sizeof()" when using Variables

I'm trying to work on some code that requires me to count the number of elements within an array. While I can get the code to work properly when I specifically call the array in the Void loop, trying to do so with a Void Function gives me issues. This first block of code works, and will properly print 30 without fail.

int numElements;

int HeartOutline[30]={130,125,156,99,164,91,186,69,198,57,216,39,232,23,233,22,
                    234,138,117,21,212,148,107,43,204,179,172,83,76,51};


void loop() {

  numElements=(sizeof(HeartOutline) / sizeof(HeartOutline[0]));
  Serial.println(numElements);

}

When I do it this following way, however, it prints a 1 each time. I assume it's something to do with the ArrayToCheck variable not knowing how may entries to hold, but I don't know how this is fixable or even if this is correct.

Anyone know how to fix this?

int numElements;

int HeartOutline[30]={130,125,156,99,164,91,186,69,198,57,216,39,232,23,233,22,
                    234,138,117,21,212,148,107,43,204,179,172,83,76,51};


void CheckSizeOf(int ArrayToCheck[]) {

  numElements=(sizeof(ArrayToCheck) / sizeof(ArrayToCheck[0]));
  Serial.println(numElements);

}


void loop() {
        CheckSizeOf(HeartOutline);
}
void CheckSizeOf(int ArrayToCheck[])

You are passing a pointer into the function. It has no way of knowing how many elements that pointer is pointing to. Normally you pass the size of the array into the function so that it can know this information.

Your array size is a constant, so you can evaluate this at compile time without waiting for a run time statement.

#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))

int HeartOutline[30]={130,125,156,99,164,91,186,69,198,57,216,39,232,23,233,22,
                    234,138,117,21,212,148,107,43,204,179,172,83,76,51};
const int numElements = ARRAY_SIZE(HeartOutline);

That does make some sense why I was running into errors.

So if I had a list of 3 or so arrays and wanted to run a function for each to check their size during runtime, would this type of structure work still, since the size of the three arrays would each be different?

I am not sure what you are trying to achieve with this, as you already know the number of elements in the array as you are declaring it of that size. So I think whether you use it this way

const int numElements = 10;
int myArray[numElements] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

or this way

int myArray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
const int numElements = ARRAY_SIZE(myArray);

you already know the size.

If you have more than one array then you need to have a variable for the size for each array. You can use ARRAY_SIZE but only when the actual array name is used as it needs to be in scope for the compiler to know its size. This should should be ALL the time that you are passing the actual array to a function. For example, this would work

void loop() 
{
        DoSomethingWithArray(HeartOutline, ARRAY_SIZE(HeartOutline));
}

with suitable declaration of parameters in the called function.