Listing 5

#define DM1init

#define DM1type                 double *

DM1init;

DM1type DM1alloc(int r, int c) {
   return (double *)
      malloc((unsigned)r*c*(sizeof(double)));
}

#define DM1item(x,i,j,c)       x[(i)*(c)+(j)]

void DM1free(DM1type x) {
   free((void *)x);
}

main()
{
   DM1type m;
   int i,j;

   m = DM1alloc(7,13);
   for(i=0; i<7; ++i)
      for(j=0; j<13; ++j)
         DM1item(m,i,j,13) = (double) (i*100)+j;

   for(i=0; i<7; ++i) {
      for(j=0; j<13; ++j)
         printf("%3g ",DM1item(m,i,j,13) );
      printf("\n");
   }
   DM1free(m);
}
/* End of File */