#include<stdio.h>
#define container_of(addr,type,field) ((type*)((unsigned char*)addr - (unsigned long)&((type*)0)->field))
struct test_struct {
float f1;
int num;
char ch;
};
int main(void)
{
struct test_struct *test_struct;
struct test_struct init_struct ;//={12,'a',12.3};
int *ptr_num = &init_struct.num;
init_struct.f1=(float)12.3;
init_struct.ch='a';
init_struct.num=12;
test_struct = container_of(ptr_num,struct test_struct,num);
printf("test_struct->num =%d\n",test_struct->num);
printf("test_struct->ch =%c\n",test_struct->ch);
printf("test_struct->f1 =%f\n",test_struct->f1);
while(1);
return 0;
}