Originally Posted by
nonlinearly
Because pa is a pointer to an integer and a is a pointer to an array of integers.
pa is a pointer to an int. a is an array, not a pointer to an array of integers. This declares a pointer to an array of 10 int:
Originally Posted by
nonlinearly
Of course the first code works maybe because it happens an implicit cast (conversion). Am I right?
Yes, a is converted to a pointer to its first element, i.e., a pointer to an int. The cast is unnecessary.
Originally Posted by
Tibo-88
A pointer to an array of integer is an int *, so there is no need for conversion, since pa and a are of the same type.
No, that is not true. pa and a are not of the same type. It is easy to demonstrate by running this program:
Code:
#include <stdio.h>
int main(void)
{
int a[10];
int *pa;
printf("%u %u\n", sizeof(a), sizeof(pa));
return 0;
}
if a and pa were of the same type, then sizeof(a) == sizeof(pa) must be true.