Quote:
Originally Posted by mr.anandc
Here my doubt is, if ptr value is 0 which is NULL, why access to b using ptr (ptr->b) is not crashing

.
Thanks.
That is Now your Intelligent question!!!
Code:
#include<stdio.h>
#include<stdlib.h>
#define offsetof(s,m) (size_t)&(((s *)0)->m)
#define Off(i,j) ((i*)0)->j
struct Data
{
int a;
int b;
};
int main()
{
int OffSet=offsetof(Data, b);
printf("%d", OffSet) ;
return 0;
}
In above code , You are only getting the address not accessing.
int main()
{
int Add=Off(Data , b);
printf("%d", Add) ;
return 0;
}
In this code , now you are accessing so segmentation fault will come.