// Construct an array of length MAX_POINTS.
// Populate the array with given points and initialize the number points being handled.
// Print the given points for the user.
struct Point points[MAX_POINTS];
int numPoints = readPoints(points);
printf("Set of points: \n");
displayPoints(points, numPoints);
// Construct an array to represent the hull with max possible points (numPoints).
struct Point hull[numPoints];
struct Point pointOnHull = leftmostPoint(points, numPoints);
struct Point endPoint;
int e = 0;
// Perform Jarvis March.
do {
hull[e] = pointOnHull;
endPoint = points[0];
for ( int i = 1; i < numPoints; i++ )
if ( (endPoint == pointOnHull) || (ccw(hull[e], endPoint, points[i]) > 0) )
endPoint = points[i];
++e;
} while ( endPoint != hull[0] ); // we've looped back to the beginning.
// Print the mapped hull points.
printf("Convex hull: \n");
displayPoints(hull, numPoints);
That's my code for a Jarvis March (gift wrapping) program to solve for convex hull. GCC is raising errors on both of my struct Point comparisons (endPoint == pointOnHull
and endPoint != hull[0])
. I'm brand new to C, and this is one of the first projects that I'm doing to play around with the language. Can anyone help me see where I'm messing up?
The specific errors:
jarvis.c:31:19: error: invalid operands to binary == (have 'struct Point' and 'struct Point')
jarvis.c:34:21: error: invalid operands to binary != (have 'struct Point' and 'struct Point')