I have a 20x20 matrix. I want to extract chunks of data from the matrix. I have
int theMatrix[20][20] = {};//Full code initializes with #'s
int *theMatrixPointer = &theMatrix;
But then I get a compiler warning saying
warning: initialization from incompatible pointer type
I went ahead and ran the code and it looks to be moving across the matrix from left to right. At least in the short run. The implementation:
//left to right with pointer;
while(theMatrixPointer)
{
int one = 0;
int two = 0;
int three = 0;
int four = 0;
double currentProduct = 0;
//int stop = 0;
for(int i = 0; i < depth; i++)
{
/*if(!theMatrixPointer)
{
stop = 1;
break;
}*/
int currentValue = *theMatrixPointer++;
printf("%d\n",currentValue);
if(i == 0)
{
one = currentValue;
}
else if (i == 1)
{
two = currentValue;
}
else if (i == 2)
{
three = currentValue;
}
else if (i == 3)
{
four = currentValue;
}
}
/*if(stop)
break;*/
currentProduct = one * (double)two * three * four;
printf("PRODUCT: %f\n",currentProduct);
startPoint++;
theMatrixPointer = startPoint;
}
...breaks over time as the data is garbage (big ints that are not in the matrix). So, how can I properly iterate this matrix with a pointer?