Logo

Programming-Idioms

History of Idiom 27 > diff from v4 to v5

Edit summary for version 5 by :

Version 4

2015-08-19, 19:30:53

Version 5

2015-08-20, 10:25:33

Idiom #27 Create a 3-dimensional array

Declare and initialize a 3D array x, having dimensions boundaries m, n, p, and containing real numbers.

Idiom #27 Create a 3-dimensional array

Declare and initialize a 3D array x, having dimensions boundaries m, n, p, and containing real numbers.

Imports
#include <stdlib.h>
Code
double ***x=malloc(m*sizeof(double *));
int i,j;
for(i=0;i<m;i++)
{
	x[i]=malloc(n*sizeof(double));
	for(j=0;j<n;j++)
	{
		x[i][j]=malloc(p*sizeof(double));
	}
}