Hello everyone!!
I am new to Linux forum and have a question related to typecasting in C related to offset of structures.I have a piece of code and having a problem with this:
void fun(struct c *p)
{
int offset;
struct b *address;
offset=(char *)&((struct c *)(&((struct a*)0)->y)->j)-(char *)((struct a *)0);
address=(struct b *)((char*)&(p->j)-offset);
address->i=400;
address->f=3.14;
address->ch='c';
printf("%u",offset);
}
As you can see that this code is accessible in turbo C but not in Dev C++ and please anybody tell me why is this so and any method to easily typecast structures for finding their offset.