Struct Pointer Parameters
If you want to change a component of a struct variable, pass a pointer to the struct
typedef struct { � } Pair; // As before
void fr (Pair * p)
{(*p).a= 42;}
void main (void) {
Pair pr;
pr.a= 17;
pr.ch= �?�;
fr(&pr)
}
Abbreviation. In C, instead of writing
( * p) . a
one can write
p ->a
Previous slide
Next slide
Back to first slide
View graphic version