Will this trick work in C?

后端 未结 5 958
终归单人心
终归单人心 2021-01-21 15:50

I want to add a field to a structure in C. So for example I have the following structure.

struct A
{
 some_type x;
 some_type y;
}

I declare a

5条回答
  •  清酒与你
    2021-01-21 16:34

    Why not just call the method on the member?

    some_function( &b->a );
    

    Your code works now, but what if somebody decides to change the members of B? Or add a new member before a?

提交回复
热议问题