数组和指针数组之间的区别编译一次? [英] Difference between an array and a pointer to an array once compiled?
问题描述
无效M(){
烧焦一个[] = {1,2,3,4,5,6,7,8,9};
炭(* C)[3] [3] =(炭(*)[3] [3])一个;
的printf(%d个\\ N,* C [0] [0]);
}
有关实例,在该功能的变量 A
指向存储器中的行9的整数的位置。
但是关于什么C
?请问 C
指向一个内存位置指向一个位置保存在连续9的整数内存?
所以,从技术上来说,是 C
单层指针或双层指针?
应该不是我上面说的是真的吗?为什么当我执行以下功能:
无效M(){
烧焦一个[] = {1,2,3,4,5,6,7,8,9};
炭(* C)[3] [3] =(炭(*)[3] [3])一个;
的printf(%d个\\ N,* C [0] [0]);
的printf(一...%P \\ NC ...%P \\ N,A,C);
}
A和C都指向同一个位置吗?如果不是C是一个双层指针,一个是指向一个内存位置?
变量
A
指向内存中连续9的整数位置。
块引用>没有。变量
A
的是的内存中的位置,一排9的整数。A
仅仅是该位置的名称。
ç是否指向一个内存位置指向一个位置保存9整数连续记忆?
块引用>没有。
C
的是的内存中的一个位置,它指向一个位置保存在连续9整数内存。C
是包含指针位置的名称。
所以,从技术上来说,是C单层指针或双层指针?
块引用>单。
void m() { char a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; char(*c)[3][3] = (char (*)[3][3])a; printf("%d\n", *c[0][0]); }
For instance, in this function the variable
a
points to a location in memory with 9 integers in a row.But what about
c
? Doesc
point to a location in memory which points to a location in memory that holds 9 integers in a row?So, technically, is
c
a single layer pointer or a double layer pointer?Shouldn't what I said above be true? How come when I execute the below function:
void m() { char a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; char(*c)[3][3] = (char (*)[3][3])a; printf("%d\n", *c[0][0]); printf("a...%p\nc...%p\n", a, c); }
a and c both point to the same locations? Shouldn't c be a double layer pointer, and a be a pointer to a location in memory?
解决方案the variable
a
points to a location in memory with 9 integers in a row.No. The variable
a
is a location in memory with 9 integers in a row.a
is just a name for that location.Does c point to a location in memory which points to a location in memory that holds 9 integers in a row?
No.
c
is a location in memory which points to a location in memory that holds 9 integers in a row.c
is a name for the location containing the pointer.So, technically, is c a single layer pointer or a double layer pointer?
Single.
这篇关于数组和指针数组之间的区别编译一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!