Are a, &a, *a, a[0], &a[0] and &a[0][0] identical pointers?

后端 未结 8 1613
南旧
南旧 2020-11-27 17:45

I have the following C program:

#include 

int main(){
    int a[2][2] = {1, 2, 3, 4};
    printf(\"a:%p, &a:%p, *a:%p \\n\", a, &a, *         


        
8条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 18:10

    This also means that in C arrays have no overhead. In some other languages the structure of arrays is

    &a     -->  overhead
                more overhead
    &a[0]  -->  element 0
                element 1
                element 2
                ...
    

    and &a != &a[0]

提交回复
热议问题