I am trying to access the data of a pointer that is a member of a struct.
typedef struct
{
int i1;
int* pi1;
} S;
int main()
{
S s1 = { 5 , &(s1.i1) };
printf("%u\n%u\n" , s1.i1 , s1.pi1 ); //here is the problem
return 0;
}
The problem lies in the second argument of printf. When i run the program i get the following result in console: 5 ...(next line) 2381238723(it's different every time). This is correct, and the result is not unexpected. I have tried things like:
*(s1.pi1)
and
s1.*pi1
None of them works. Is there any operator in C or method to do this?