[Solved] Struct name *ptr = (Same struct name *) p2; [closed]


Starting at the left hand side:

struct foo *ptr

declares ptr to be of type struct foo *, that is a pointer to struct foo.

The = initializes that ptr variable to whatever the right hand side evaluates as.

And the right hand side

(struct foo *) p2

is an expression that casts p2 to be of type struct foo *.

1

solved Struct name *ptr = (Same struct name *) p2; [closed]