Listing 2

#include <stdio.h>
#include <stdlib.h>

main()
{
   int rows = 0;
   long **pl;
   int i;

   while (rows < 1) {
       printf("Enter number of 10 element rows: ");
       scanf("%4d", &rows);
   }

   pl = malloc(rows * sizeof(long *));
   if (pl == NULL) {
       printf("malloc of pl failed\n");
       exit(1);
   }

   for (i = 0; i < rows; ++i) {
       pl[i] = malloc(10 * sizeof(long));
       if (pl[i] == NULL) {
           printf("malloc of pl[%d] failed\n", i);
           exit(1);
       }
   }

   pl[0][2] = 1234;
   pl[0][9] = 9876;
}