Hi,
This is essentially the code to find the offset of member 'b' from the beginning of the struct 'blah'. The book I was reading said typecasting 0 into the struct 'blah' was fine as long as we didn't dereference it. I agree with that, but I see that the code uses the '->' operator in conjunction with the '&' to get the address. I was under the impression that 'tmp->b' is basically synonymous to '(*tmp).b'. Doesn't this imply that 'tmp' would first be dereferenced before the address is gotten? If so, shouldn't it be an out of bounds error? Or is it fine because the compiler optimises it somehow so that 'tmp' is never actually dereferenced? Any insight would be appreciated. Thanks in advance.Code:struct blah { int a; int b; }; struct blah *tmp = (struct blah *) 0; printf("%p\n", &tmp->b);