Why is it a compile error to assign the address of an array to a pointer “my_pointer = &my_array”?

后端 未结 3 1311
北荒
北荒 2020-12-09 18:10
int my_array[5] = {0};
int *my_pointer = 0;

my_pointer = &my_array // compiler error
my_pointer = my_array // ok

If my_array is a

3条回答
  •  孤城傲影
    2020-12-09 18:51

    &my_array is the address at which the value of my_array is stored, i.e., it is the address of the address of the array and has type int**.

提交回复
热议问题