Casting one C structure into another

前端 未结 8 676
再見小時候
再見小時候 2020-11-27 03:30

I have two identical (but differently named) C structures:

typedef struct {
      double x;
      double y;
      double z;
} CMAcceleration;


typedef struc         


        
8条回答
  •  抹茶落季
    2020-11-27 04:02

    You use an utility function for that:

    void AccelerationToVector( struct CMAcceleration* from, struct Vector3d* to )
    {
         to->x = from->x;
         to->y = from->y;
         to->z = from->z;
    }
    

提交回复
热议问题