12.6k views
3 votes
typedef struct point { float *p; struct { float x; float y; } s; struct point* next; } point; void func(point *sp1, point* sp2) { sp2->p = A; sp2->s.x = B; sp2->s.y = C; } int main() { point *init, *final; // assume init has been initialized to some value; func(init, final); return 0; }

1 Answer

5 votes

Answer:

Check the explanation

Step-by-step explanation:

Value of A is sp1->p.

Since A is the part that we are assigning value to sp2->p and to that function two points sp1 and sp2 are passed and we are copying sp1 contents to sp2.

so for sp2->p, sp1->p is the correct assignment.

Value of B is sp1->s.x. Since s is a another structure that is defined inside point so we are accessing through -> operator and x is variable inside s so sp1->s.x is the

correct assignment.

Similarly Value of c is sp1->s,y

User Oke Tega
by
3.5k points