我在學習C,現在我在指針中發生混亂。我的問題是,爲什麼不printf(「%d」,*(i));使用多維數組時返回元素而不是地址?C中指針的混亂
#include <stdio.h>
int main()
{
int i[2][2] = {{1,8},{2,9},{3, 4}};
//int i[2] = {1,2,3};
printf("%d", *(i));
printf("\n%d", i);
}
我在學習C,現在我在指針中發生混亂。我的問題是,爲什麼不printf(「%d」,*(i));使用多維數組時返回元素而不是地址?C中指針的混亂
#include <stdio.h>
int main()
{
int i[2][2] = {{1,8},{2,9},{3, 4}};
//int i[2] = {1,2,3};
printf("%d", *(i));
printf("\n%d", i);
}
因爲多維數組可以寫爲**我所以你在做*(i)給你第一個數組的地址。
請注意,在你的代碼中,'i'的長度是2,但初始化程序有3個元素。 –