指针结构成员 [英] pointer to member of struct
本文介绍了指针结构成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图写一个C程序。我需要变量recq的地址。有人可以请帮我可以认识到这一点?
typedef结构{
诠释recq;
} DD;
结构试验{
DD一个;
};主要(){
结构测试*毫米;
MM =(结构测试*)malloc的(的sizeof(结构测试));
SS =及(MM-> a.recq);
的printf(%P,SS);}
解决方案
您有什么看起来不错,除非你需要声明SS变量:
为int * SS;
I am trying to write a C program. I need the address of variable "recq". Can someone pls help me figure that out?
typedef struct {
int recq;
} dd;
struct test {
dd a;
};
main(){
struct test *mm;
mm=(struct test *) malloc (sizeof (struct test));
ss=&(mm->a.recq);
printf("%p",ss);
}
解决方案
What you have looks good except you need to declare the ss variable:
int *ss;
这篇关于指针结构成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文