This is fine with my compiler (Output is 3.000000), but I'm unsureCode:#include <stdio.h> typedef struct { double x, y, z; }vector; double *vector_iterator(vector *v, int axis) { switch (axis) { case 0: return (&v->x); case 1: return (&v->y); case 2: return (&v->z); } } int main(void) { vector v; v.x = 5; v.y = 3; v.z = 2; *(vector_iterator(&v, 0)) = 3; /* Note this */ printf("%f", v.x); return 0; }
about function call on the left side of = operator (lvalue ?)