2017-02-15 75 views
-1
#include<stdio.h> 
int main() 
{ 
    int a[2][3] = {3,5,4,7,9,0}; 
    int i, j; 
    for (i=0; i<2; i++) 
    { 
    for (j=0; j<3; j++) 
    printf(「%p\n」, *(a+i) +j); // Statment 1 
    } 
} 

正如你所看到的,爲什麼標記的語句意味着它是一個地址指向二維array[a]?這是不是意味着array[a]的值?我不明白星號是否意味着它從(a + i)中獲得價值?關於二維數組地址。這個說法是什麼意思?

回答

0

這是一個例子,我在谷歌

int a=9; 
int *b = &a; 
printf("%p\n",b); 

發現在Win32系統,以下結果將打印:

0018FF20

因此,大家可以看到,說明符p用於獲取指針當前指向的地址。

As a result *(a+i)+j would give you the address where the pointer is pointing in a 2-D array 
As a result *(a+0)+0 would give you the 1st row and 1st column address 
*(a+0)+1 would give you the 1st row and 2nd column address 
*(a+1)+0 would give you the 2nd row and 1st column address.