I am trying to pass a double-dimensional array to a function, but it throws this error all the time. My code is below:
void initialize_centroids(int *,int,int);(Initialization)
initialize_centroids(centroid[0],noofcentroids,newnoofvar);(inside my main)
void initialize_centroids(int *carray,int p,int q)
{
int i,j;
for(i=0;i<p;i++)
{
for(j=0;j<q;j++)
{
carray[i][j]=i;
}
}
return;
}
You’re passing a pointer to an int (
int*), but you’re trying to use two subscripts. Is it a 2D array? Then the parameter needs to be a pointer to a pointer to an int:int**