I get an error/warning when trying to get the minimum/maximum values from the points in the main function. How can I calculate the max/min points? Is there any easier method? Am i supposed to use a structure?
test.c:73:14: warning: incompatible pointer types passing 'int [100][100]' to parameter of type 'int *' [-Wincompatible-pointer-types] convexHull(points, n); test.c:33:21: note: passing argument to parameter 'point' here void convexHull(int point[], int n) ^ 1 warning generated.**
void convexHull(int point[], int n)
{
int i;
//n is the size
int min_x=0;
int max_x=0;
if (n <3)
{
printf("Convex hull can't have less than 3 points\n.");
}
//Finding point with min/max x-coordinate.
for (i=1;i<n;i++)
{
if (point[i] < point[min_x])
{
min_x=i;
}
if (point[i] > point[max_x])
{
max_x = i;
}
}
printf("%d\n",max_x);
printf("%d\n",min_x);
}
int main()
{
int n;
int points[100][100] = {{0, 3}, {2, 2}, {1, 1}, {2, 1},
{3, 0}, {0, 0}, {3, 3}};
n = sizeof(points)/sizeof(points[0]);
convexHull(points, n);
return 0;
}
n
will be 10000, so way out of bounds. – stark