Regarding C typedef struct
- by Bruce Duncan
I have multiple instances of typedef struct box so box box1, box box2 etc.
The members of the struct are length, width, height etc.
typedef struct
{
int width;
int height;
} box;
box box1;
box box2;
How can I create a function that operates on all the width members of each
box instance? My confusion is how do I pass a pointer to a typedef struct member
that works across all instances of box. I know how to pass a pointer to a specific
instance member like box1.width but how to pass .width and then do
box1.width=value;
box2.width=value;
box3.width=value;
within the function?