arr[0] is a one-dimensional array, &arr[0] is a pointer to a one-dimensional array, &arr[0]+1 is also a pointer to a one-dimensional array, *(&arr[0]+1) is a one-dimensional array, and the array is When making an rvalue, it is automatically converted into a pointer. This is the explanation in C language
arr[0] is an array, and &arr[0] is a pointer to the array. In fact, it can also be understood as the address of arr[0], but the compiler knows its type, so it is called a pointer. But there is no place in the actual memory to store the address of &arr[0] or arr[0]. It is not like the variable b. b is declared and the compiler allocates memory space to it, so you can use the address & to get the address of b.
arr is an array, and each member of it is an array int [2]. The length of each member is 8 bytes. arr + 1 is converted into a pointer to the array when doing this operationint (*)[2], so the value of arr + 1 is the address of array arr + 8. It is not only an address, but the compiler knows the type of data it points to. This is a pointer in the concept of C language. So *(arr+1) is arr[1].
*(arr+1) represents the content in the memory, but this content happens to be an array. The array is automatically converted into a pointer to the array member, so what is printed is the address. If it is int arr1[2], then *(arr1 + 1) is different.
arr[0]
is a one-dimensional array,&arr[0]
is a pointer to a one-dimensional array,&arr[0]+1
is also a pointer to a one-dimensional array,*(&arr[0]+1)
is a one-dimensional array, and the array is When making an rvalue, it is automatically converted into a pointer. This is the explanation in C languagearr[0]
is an array, and&arr[0]
is a pointer to the array. In fact, it can also be understood as the address ofarr[0]
, but the compiler knows its type, so it is called a pointer. But there is no place in the actual memory to store the address of&arr[0]
orarr[0]
. It is not like the variableb
.b
is declared and the compiler allocates memory space to it, so you can use the address&
to get the address ofb
.arr
is an array, and each member of it is an arrayint [2]
. The length of each member is 8 bytes.arr + 1
is converted into a pointer to the array when doing this operationint (*)[2]
, so the value ofarr + 1
is the address of arrayarr
+ 8. It is not only an address, but the compiler knows the type of data it points to. This is a pointer in the concept of C language. So*(arr+1)
isarr[1]
.*(arr+1)
represents the content in the memory, but this content happens to be an array. The array is automatically converted into a pointer to the array member, so what is printed is the address. If it isint arr1[2]
, then*(arr1 + 1)
is different.Related topics