As the title says, I am trying to transpose a 2 dimensional matrix by calling by reference. I have attached my code below. When I run the code, the 2 dimensional array is unchanged.
#include <stdio.h>
#define SIZE 4
void transpose2D(int ar[][SIZE], int rowSize, int colSize);
int main()
{
    int testArr[4][4] = {
        {1, 2, 3, 4},
        {5, 1, 2, 2},
        {6, 3, 4, 4},
        {7, 5, 6, 7},
    };
    transpose2D(testArr, 4, 4);
    // print out new array
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            printf("%d ", testArr[i][j]);
        }
        printf("\n");
    }
    return 0;
}
void transpose2D(int ar[][SIZE], int rowSize, int colSize)
{
    for (int i = 0; i < rowSize; i++)
    {
        for (int j = 0; j < colSize; j++)
        {
            int temp = *(*(ar + i) + j);
            *(*(ar + i) + j) = *(*(ar + j) + i);
            *(*(ar + j) + i) = temp;
        }
    }
}
Have been stuck for a couple of hours, any help is greatly appreciated, thank you!
 
     
    