sizeof single struct member in C

后端 未结 9 2221
礼貌的吻别
礼貌的吻别 2020-11-30 17:13

I am trying to declare a struct that is dependent upon another struct. I want to use sizeof to be safe/pedantic.

typedef struct _parent
{
  floa         


        
9条回答
  •  心在旅途
    2020-11-30 17:51

    Another possibility would be to define a type. The fact that you want to ensure the same size for the two fields is an indicator that you have the same semantics for them, I think.

    typedef char description[255];
    

    and then have a field

    description text;
    

    in both of your types.

提交回复
热议问题