So I've tried to implement the function that gets the minor (The submatrix). Here is the code:

Code:

int **minor(int **matrix, int order, int element){
int **submatrix = (int **)malloc(sizeof(int) * (order - 1)); /*allocating memory for the submatrix*/
int row = -1, column = -1,exit_loop = 0;
for (int i = 0 ; i < order ; i++){ /*Getting the exact position of the element*/
for (int j = 0 ; j < order ; j++)
if (element == matrix[i][j]){
row = i;
column = j;
exit_loop = 1;
break;
}
if(exit_loop)
break;
}
int row2 = 0;
int column2 = 0;
while(row2 != order - 1){ /*Copying the original matrix to the sub matrix (minor)*/
while(column2 != order - 1){
if(row2 != row && column2 != column)
submatrix[row2][column2] = matrix[row2][column2];
column2++;
}
row2++;
}
return submatrix;
}

Where order is the size of matrix (matrix[order][order]).

the prototype of the function is int **minor(int**,int,int)

why this call doesn't work??

Code:

int **x = minor(matrix, order, 3);

it gives me the following error:

Code:

cannot convert `int (*)[((unsigned int)((int)order))]' to `int**' for argument `1' to `int** minor(int**, int, int)'

PS: pointer function is something we didn't cover in class yet, so what you see is completely and exclusively the result of my "pointer" logic.