I am trying to get the values of diagonal values from a 2D array. For example..
10 20 30
10 20 30
10 20 30
From my codes, I will be adding/summing the numbers from index[0][0] with index1 and index[2][2] USING POINTERS which will compute to 60. However, when I build and run, it returns computation of the memory address instead. Anyone can explain the problem here? (I'm new to C programming and pointers)
void diagonals2D(int array[][SIZE], int rowSize, int colSize, int *sum)
{
int count;
*sum=0;
for(count=0;count<SIZE;count++)
{
(*sum)+=*(array+count+count);
}
}

*(array+count+count)-->array[count][count]