I've got this piece of code. It appears to dereference a null pointer here, but then bitwise-ANDs the result with unsigned int
. I really don't understand the whole part. What is it intended to do? Is this a form of pointer arithmetic?
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 output I get is 44. But how does it work?