I have printed out my sizeof(array)/sizeof(*array)
and receive the number three, but when I pass my array into my function it prints out 2 when stored into a variable and therefor iterates one less time than it should.
void printAry(int ary[])
{
int size = sizeof(ary)/sizeof(ary[0]);
cout<<size;//size will print out 2! why?
for(int i = 0; i < size;i++)
{
cout<<ary[i];
}
}
int main() {
int ary[3] = {1,2,3};
cout<<sizeof(ary[0]);
return 0;
}
Why is it iterating one time less than expected ?