so i was just playing around with the code to find array length.... the orignal code was:
#include<stdio.h>
int main()
{ int al;
int a[] = {1,2,3,4,5};
al= sizeof(a) / sizeof(a[0]);
printf("%d",al);
return 0;
}
which gave me the output of:
5
but when i changed the expression to:
al= sizeof(&a[0]) / sizeof(a[0]);
it gave me the output of
2
if a is the same as &a[0] ...then why does this happen?
Also, if put &a in place of &a[0] the answer is also 2.
if "a" is the same as "&a[0]" ...then why does this happen?Becauseais not the same as&a[0].