Structure Element Pointer

I am trying to write a program in C. I need the address of the variable "recq". Can someone help me figure this 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); } 
+6
source share
3 answers

What you look good, except that you need to declare the ss variable:

 int *ss; 
+5
source

First of all, you need to declare ss as "int *" or use listing, the rest of your code is correct, I think.

0
source

Your required program,

 #include<stdio.h> typedef struct { int recq; } dd; struct test { dd a; }; void main(void){ struct test mm; printf("%p", &mm.a.recq); } 
0
source

Source: https://habr.com/ru/post/887335/


All Articles