Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 结构本身的地址_C_Structure - Fatal编程技术网

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。我明白了:)