int my_array[5] = {0};
int *my_pointer = 0;
my_pointer = &my_array; // compiler error
my_pointer = my_array; // ok
If my_array is address of array then what does &my_array gives me?
I get the following compiler error:
error: cannot convert ‘int (*)[5]’ to ‘int*’ in assignment
my_arrayis the name of an array of 5 integers. The compiler will happily convert it to a pointer to a single integer.&my_arrayis a pointer to an array of 5 integers. The compiler will not treat an array of integers as a single integer, thus it refuses to make the conversion.