Why does the following code produce the correct output. Ideally we should pass a
instead of &a
. But I have found that passing &a
also produces the same result. But this does not work for integer variables, it works only for arrays. Can somebody explain the logic behind it. Thanks in advance.
#include <stdio.h>
void m(int *p)
{
int i = 0;
for(i = 0;i < 3; i++)
printf("%d\t", p[i]);
}
void main()
{
int a[3] = {6, 5, 3};
m(&a);
}