When passing arrays to functions, they decay to pointers. So, your size()
function is equivalent to:
int size(int* a)
{
return sizeof a/sizeof a[0];
}
And sizeof a
is the size of a pointer, which is the same as the size of an int here, hence the output.