Create an array of triangle pointers. Initialize the array by setting each cell to NULL. Then create several triangles and put their address in some of the array cells. Print out the array, showing which cells contain null and printing triangle data for other cells. The picture shows the array with three cells filled with pointers to initialized triangles.
This code starts building the above structure. Your job is to finish the program.
#include <stdio.h>
#include <stdlib.h>
int main()
{
const int length = 8;
TriangleMod *triarray[length];
/* Initialize the array here */
????????
/* Create several array elements here */
????? = newTriangleMod();
setTriangleModPoint( ??????, 0, 245, 148 );
setTriangleModPoint( ??????, 1, -97, 32 );
setTriangleModPoint( ??????, 2, 12, -34 );
setTriangleModColor( ??????, 200, 160, 100);
. . .
/* Print out the array here. Print "null" for empty cells. */
???????
/* Free allocated memory here */
}
Don't try to free memory that has not been allocated.