如果我的二维数组是int array [4] [5] = {1,2,3,4,5,6,7,8,9,0,11,12,13,14,15,16 ,17,18,19,20};
if my two dimensional array is int array[4][5]= {1,2,3,4,5,6,7,8,9,0,11,12,13,14,15,16,17,18,19,20};
当我打印位置时:printf(%d \ n",array [2,0]);.这是在不提供&的情况下打印值的地址.但是如果我这样打印:printf(%d \ n",& array [2] [0]);它是值的打印地址.正如我给出的&它打印地址.但两者的地址不同.但是如果我打印printf(,:%d \ n",array [3,0]);它正在打印数组[2,0]的相同地址.
when I print a position: printf("%d\n",array[2,0]);. this is printing the address of the value without giving the &. but if I print like this: printf("%d\n",&array[2][0]); it is printing address of the value. As I have given the & it prints the address. but both the address are different. but if I print printf(",:%d\n",array[3,0]); it is printing the same address of array[2,0].
[2] [0]和[2,0]访问数组元素之间的区别是什么.
what is the difference between [2][0] and [2,0] accessing the array elements.
推荐答案阅读有关逗号运算符的信息. array[2][0]正在访问第三行第一列的元素. array[2,0]首先执行操作(2,0)(返回0),因此等效于array[0],后者返回数组的第一行(实际上是&array[0][0],因为它会衰减为指针).
Read about comma operator. array[2][0] is accessing element at third row, first column. array[2,0] is first executing operation (2,0) (which returns 0) and thus is equivalent to array[0], which returns the first row of array (actually &array[0][0] because it decays to a pointer).
更多推荐
array [1] [2]和array [1,2]有什么区别?
发布评论