本文介绍了这是什么的sizeof(安培;数组)的回报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
继的问题:How来到一个数组的地址,等于其在C值?
#include <stdio.h>
#define N 10
char str2[N]={"Hello"};
int main(){
printf("sizeof(str2): %d bytes\n", sizeof(str2));
printf("sizeof(&str2): %d bytes\n", sizeof(&str2));
return 0;
}
输出:
sizeof(str2): 10 bytes
sizeof(&str2): 4 bytes
我知道 STR2
单是第一个元素的数组的ADRESS STR2
。而当 STR2
是的sizeof的
参数,返回整个数组STR2的大小。
I know that str2
alone is the adress of the first element in array str2
. And that when str2
is an argument of sizeof
it returns the size of the whole array str2.
此外,&放大器; STR2
也是第一个元素改编的ADRESS STR2
但是从不同势型(字符(*)[N]
==指针数组)。但如何&放大器; STR2
行为时,它的的sizeof的
In addition, &str2
is also the adress of the first element in arr str2
but from diffrent type (char (*)[N]
== pointer to array). But how &str2
behaves when it's an argument of sizeof
?
推荐答案
&放大器; STR2
是一个指针。所以你刚才看到的sizeof指向您的平台。
&str2
is a pointer. So you're just seeing the sizeof a pointer on your platform.
这篇关于这是什么的sizeof(安培;数组)的回报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!