I get a segmentation fault when I run this program. I attempted debugging, and I think the problem is in my pointer B, but I don't know why. The fault comes in the function "loesen" as soon as B is used

Code:#include <stdio.h> int k=4; int eingabe(int i, int j, int n, int k, double **A, double *B){ A = malloc(k * sizeof(**A)); for(i=0; i<k; i++) A[i]=malloc(k * sizeof(**A)); printf("Geben Sie ein Oberematrix Reihweise ein\n"); for(i=0; i<k; i++){ for(j=i; j<k; j++){ scanf("%lf", &A[i][j]); } } B = malloc(k * sizeof(*B)); printf("Geben Sie Loesung Vektor ein\n"); for(i=0; i<k; i++) scanf("%lf", &B[i]); return 0; } int ausgabe(int i, int k, double *X){ for(i=0; i<k; i++) printf("%lf", X[i]); return 0; } int loesen(int i, int j, int k, int n, double det, double *X, double *B, double **A, double summe){ X = malloc(k * sizeof(*X)); summe = 0; n = k-1; X[n] = B[n] / A[n][n]; for(i=0; i<k; i++){ for(j=i+1; j<n; j++) summe += A[i][j] * X[j]; X[i] = (1/A[i][i])* (B[i]-summe); } for(i=0; i<k; i++) det *= A[i][i]; if(det==0) printf("Matrix ist Singulaer\n"); return 0; } int main(){ int i, j, n; double *X, *B, **A, summe, det; eingabe( i, j, n, k, A, B); loesen( i, j, k, n, det, X, B, A, summe); ausgabe( i, k, X); getch(); return 0; }