void sum_col(int *ar, int rows)
{
int c, r, total;
for (c = 0; c < 4; c++)
{
total = 0;
for (r = 0; r < rows; r++)
total += ar[r][c]; // error occurs
printf("%dth column sum: %d", c + 1, total);
}
}
I'm trying to define a function which prints column sums of a 2 dimensional array. But error occurs in total += ar[r][c]
. What's wrong with this sentence?