Here is the Triangle type,
a Triangle variable tri,
and a variable triptr that points to a Triangle:
typedef struct
{
int x, y;
} Point;
typedef struct
{
int red, green, blue;
} Color;
typedef struct
{
Point p0, p1, p2;
Color color;
} Triangle;
int main ()
{
Triangle tri ;
Triangle *triptr ;
triptr = (Triangle *)malloc( sizeof(Triangle) );
. . .
}
At this point, neither triangle is initialized.
The identifier tri is the name for
the memory
of a Triangle.
That memory can be assigned values by statements like:
tri.p0.x = 45; tri.p0.y = 97;
The variable triptr
holds a pointer to the memory of a Triangle.
That memory can be assigned values by statements like:
triptr->p0.x = 45; triptr->p0.y = 97;