I am stuck in c structure program. I don't have idea What happens inside if statement in code
I guess p is structure pointer point to memory location of structure member x.
My confusion is whether the pointer is dereferenced or not ?
Code:
#include<stdio.h>
#include<stdlib.h>
struct s
{
int x;
int y;
};
int main ()
{
struct s *p = NULL;
p = malloc(sizeof(*p));
if ( p != NULL )
{
printf("%d\n", p-> x);
p = p -> y;
}
free (p );
return 0;
}
Code:
printf("%d\n", p-> x);
My confusion is whether the pointer is dereferenced or not ?