Array size using sizeof operator

vector cellCompete(int* states, int days)
{
}

the function signature is like this. states is an array of integers containing 0 or 1.

I am getting the wrong length using sizeof() operator.

this is because states is actually a pointer

so when you do sizeof(states) it will give you size of pointer not the size of array

that’s is why we have to pass size of array in function every time along with array

if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like :heart:: and don’t forgot to mark doubt as resolved :grinning: