home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l351 / 1.ddi / EXAMPLES / BIG.C next >
Encoding:
C/C++ Source or Header  |  1993-01-26  |  727 b   |  35 lines

  1. /* BIG.C */
  2.  
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <malloc.h>
  6.  
  7. #define NROWS    512
  8. #define NCOLS    512
  9. #define    ARSIZE    ((long)NROWS * sizeof(long [NCOLS]))
  10.  
  11. main()
  12. {
  13.     int i, j;
  14.  
  15.     long (huge * array)[NCOLS];
  16.     array = (long (huge *)[NCOLS]) _halloc ( NROWS, sizeof(long [NCOLS]) );
  17.     if( ! array )
  18.     {
  19.     printf("Can't allocate %lu-byte array, giving up!\n", ARSIZE);
  20.     return 1;
  21.     }
  22.  
  23.     printf("Using %lu-byte array\n", ARSIZE);
  24.  
  25.     for (i=0; i<NROWS; i++)
  26.     {
  27.         for (j=0; j<NCOLS; j++)
  28.             array[i][j] = (long) i * j; /* touch every element */
  29.         printf("%d\r", i);              /* display odometer */
  30.     }
  31.  
  32.     printf("done\n");
  33.     return 0;
  34. }
  35.