Possible Duplicate:
Sizeof an array in the C programming language?
Why sizeof(param_array) is the size of pointer?
void printSizeOfArray(int a[])
{
printf("%lu\n", sizeof(a));
}
int main()
{
int it;
int a[4] = {0};
printSizeOfArray(a);
return 0;
}
When I run the code I get 8. Why is a pointer to an array a pointer of type void?
And if a pointer to an array is of type void, why, when I write:
int *it;
int a[4] = {0};
it = a;
printf("%lu\n", sizeof(it));
It works ok as well? How can I point with an int?
Also, why does it print 8 in the second and not 4? It is a pointer to array (void*) and not an int.
Why is a pointer to an array a pointer of type void?First problem with this question is there are no pointers in your first block of code... Second overall question pointers are not arrays, arrays are not pointers.Why is a pointer to an array a pointer of type void?come from?