int** transpose(int** A, int ASize, int* AColSize, int* returnSize, int** returnColumnSizes){ int** arr = (int**)calloc(*AColSize,sizeof(int*)); for (int i=0; i<*AColSize; i++) { int* row = (int*)calloc(ASize,sizeof(int)); for (int j=0; j<ASize; j++) { row[j] = A[j][i]; } (*returnColumnSizes)[i] = ASize; arr[i] = row; } *returnSize = *AColSize; return arr; }