C 结构本身的地址
如何找到结构本身的地址? 我听说结构的第一个变量指向结构的地址。我不清楚这件事。任何人都可以解释如何找到这个?给定:C 结构本身的地址,c,structure,C,Structure,如何找到结构本身的地址? 我听说结构的第一个变量指向结构的地址。我不清楚这件事。任何人都可以解释如何找到这个?给定: struct mystruct { int first; int second; }; struct mystruct thing; 然后&thing和&(thing.first)是相同的(&是操作员的“地址”) 作为一个完整的程序: #include <stdio.h> struct mystruct { int first;
struct mystruct {
int first;
int second;
};
struct mystruct thing;
然后&thing
和&(thing.first)
是相同的(&
是操作员的“地址”)
作为一个完整的程序:
#include <stdio.h>
struct mystruct {
int first;
int second;
};
int main ( void ) {
struct mystruct thing;
printf("&thing is %p, &(thing.first) is %p\n",
&thing, &(thing.first));
return 0;
}
#包括
结构mystruct{
int优先;
int秒;
};
内部主(空){
结构我的结构物;
printf(“&thing是%p,&(thing.first)是%p\n”,
&事物&(事物第一);
返回0;
}
%/astest&thing是0x7fff57513910,&(thing.first)是0x7fff57513910
@萨胡,好的。谢谢你的回复。谢谢你@john。我明白了:)