NULL pointer dereference in C
- by user554125
hey ive got this piece of code. It dereferences a null pointer here. But then there is an and with unsigned int. I really dont understand the whole part. Can someone explain the output.??
struct hi
{
long a;
int b;
long c;
};
int main()
{
struct hi ob={3,4,5};
struct hi *ptr=&ob;
int num= (unsigned int) & (((struct hi *)0)->b);
printf("%d",num);
printf("%d",*(int *)((char *)ptr + (unsigned int) & (((struct hi *)0)->b)));
}
The o/p i get is 44 .But how does it work?