Problem with functions calling functions - C

-1

I am doing a program to demonstrate the application of relationships.

I need to call the functions:

int injetora(int M[N][N]){
    int i,j,cont;
    for(j=0; j<N; j++){
        cont = 0;
        for(i=0; i<N; i++){
            cont += M[i][j];
            if (cont > 1) return 0;
        }
    }return 1;
}

int total(int M[N][N]){
    int i,j,cont;
    for(i=0; i<N; i++){
        cont = 0;
        for(j=0; j<N; j++){
            cont += M[i][j];
        }
        if (cont < 1) return 0;
    }return 1;
}

I need to call these two functions within this other function:

int monomorfismo (int M[N][N]){
    int boole;
    boole = total(M[N][N]);
    if (boole == 1){
        boole = injetora(M[N][N]);
        if (boole == 1){
            return 1;
        }else{  
            return 0;
        } 
    }
    return 0;
}

I just can not do it. When running the program it completely crashes with the error message:

[Warning] passing argument 1 of 'total' makes pointer from integer without a cast
    
asked by anonymous 10.09.2018 / 13:25

1 answer

0

Your error is in the function call.

int injetora(int M[N][N]) indicates that you will receive an array as a parameter, however only one integer is passed. The call should only have the name of the variable (without column / row indication):

int monomorfismo (int M[N][N]){
    int boole;
    boole = total(M);
    if (boole == 1){
        boole = injetora(M);
        if (boole == 1){
            return 1;
        }else{  
            return 0;
        } 
    }
    return 0;
}
    
10.09.2018 / 13:41