Here I'm dealing with ' DMA to matrices ' which is very confusing me when its comes to additions of dynamically allocated matrices.
This is how I created a multi-dimensional
int main(void)
{
    int ***array, rows, columns, matrices, *arraySum;
    printf ("\n Enter Number of Matrices : ");
    scanf ("%d", &matrices);
    printf ("\n Enter Number of Rows : ");
    scanf ("%d", &rows);
    printf ("\n Enter Number of columns : ");
    scanf ("%d", &columns);
 //Allocating memory for matrices-array
    array = malloc ( sizeof ( array ) * matrices );
    if( !array )
    {
        perror ("Matrices-array");
        return 1;
    }
    for ( int i = 0; i < matrices; i++ )
    {
        array[i] = malloc ( sizeof ( array[i] ) * matrices );
        if ( !array[i] )
        {
            perror ("Matrix[i]");
            return 1;
        }
            printf ("\n\n Enter %d matrix elements !", i);
        for ( int j = 0; j < rows; j++ )
        {
            array[i][j] = malloc ( sizeof ( array[i][j] ) * columns );
        if ( !array[i][j] )
        {
           perror ("Matrix-rows");
           return 1;
        }
            for (int k = 0; k < columns; k++ )
            {
                  printf ("\n Enter element - [%d][%d] : ", j+1, k+1);
                  if ( scanf ("%d", &array[i][j][k]) != 1 )
                  {
                       printf("\n Wrong Input");
                       return 1;
                  }
            }
        }
        putchar ('\n');
    }
//Deallocating memories
for ( int i = 0; i < matrices; i++ )
{
    for ( int j = 0; j < rows; j++ )
    {
        free ( array[i][j] );   // 
        Deallocating memory  of matrix-rows
    }
    free ( array[i] ); // Deallocating memory  of matrices[i]
}
free ( array );
return 0;
}
This is how I tried to perform addition
for ( int i = 0; i < mat; i++ )
{
   for ( int j = 0; j < rows; j++ )
   {
       for ( int k = 0; k < columns; k++ )
       {
           for ( int a; a < columns; a++)
           {
               arraySum = malloc ( sizeof ( arraySum ) * columns;
               arraySum[a] = array[i][j][k] + array[i+1][j+1][k+1];
               
           }
       }
}
But it is not working!!!!.
This is what I want
If matrices = 2, rows = 2, cols = 3;
    a[0][0][0] + a[1][0][0];
    a[0][0][1] + a[1][0][1]
    a[0][0][2] + a[1][0][2];
    a[0][1][0] + a[1][1][0];
    a[0][1][1] + a[1][1][1];
    a[0][1][2] + a[1][1][2];*
I'm stuck , help me .
 
     
     
    