I get a bus error 10 from this code. When I put in print statements, I get a segmentation fault error. I use these two functions in a larger program to compute the determinant of the matrix. What do these errors mean? I am new to the C environment. Thanks!
int* cofactor(int* matrix, int co_row, int co_column, int size_of_matrix){
int* result;
int i, offset;
int row, column;
result = duplicate_matrix(matrix, size_of_matrix-1);
i = 0;
offset = row*size_of_matrix+column;
for (row = i; row < size_of_matrix; row++){
for (column = i; column < size_of_matrix; column++){
if ((row != co_row) && (column != co_column)){
i = offset;
i += 1;
*result = i;
}
return result;
}
}
}
int* determinant(int* matrix, int size_of_matrix){
int sign, x, one=1;
int* size;
int* result;
int* the_sign;
int* comatrix;
sign = one;
*the_sign = sign;
*size = size_of_matrix;
result = malloc(sizeof(int) * size_of_matrix*size_of_matrix);
comatrix = malloc(sizeof(int) * size_of_matrix*size_of_matrix);
if (*size == one){
return size;
}
else{
for (x = 0; x < size_of_matrix; x++){
comatrix = cofactor(matrix, 0, x, size_of_matrix);
*result = x;
*result += *matrix;
*matrix *= *the_sign;
*the_sign *= *determinant(comatrix, size_of_matrix);
*the_sign *= -1;
*result = *the_sign;
}
return result;
}
}