Say you have the following ANSI C code that initializes a multi-dimensional array :
int main() { int i, m = 5, n = 20; int **a = malloc(m * sizeo
I would call malloc() and free() only once:
#include #include int main(void){ int i, m = 5, n = 20; int **a = malloc( m*(sizeof(int*) + n*sizeof(int)) ); //Initialize the arrays for( a[0]=(int*)a+m, i=1; i