Inner struct p
is not visible to the program outside the main
function. Put your structure outside the main
.
You are confused with the identical name of inner and outer struct p
. You define the outer p
as
typedef struct p *q;
What does it mean? It means that you are defining a new type q
which is a pointer to the struct p
. But the problem is that there is no definition of struct p
type is known here.
It is true that outer p
is visible to main
but inner p
is not visible to outer p
.