having a pointer to pointer in main and create an array in other function : I have this :

    #include <stdio.h>
    #include <stdlib.h>
    
    void mad(int ***,int ,int );
    int main(void){
            int **x;
            int n,m;
    
            scanf("%d%d",&n,&m);
            mad(x,n,m);
            x[0][0] = 5;
            printf:("%d\n",x[0][0]);
            return 0;
    }
    
    void mad(int ***x,int n, int m){
            int i;
    
            **x = malloc(sizeof(int *));
            for(i=0;i<n;i++) ***(x + i) = malloc(m * sizeof(int));
    
    }

This is wrong can someone explain why this is wrong and give me the right code 