home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / CGAZV5N3.ZIP / TESTARRY.C < prev    next >
C/C++ Source or Header  |  1991-03-02  |  789b  |  25 lines

  1. /********* Listing 3 ********************** TESTARRY.C ****
  2.  * TESTARRY.C : Test the dynamic_array
  3.  * (c) C Gazette, see Listing 1 for usage.
  4.  *********************************************************/
  5. #include "array.h"
  6. #include <stdio.h>
  7.  
  8. void main() 
  9. {
  10.   int i;
  11.   dynamic_array da, *dap;
  12.   create_array(&da, 20);
  13.   for(i = 0; i < 20; i++)
  14.     *value(&da, i) = i * 2;  /* assign a value to each element */
  15.   dap = make_heap_array(20);
  16.   for(i = 0; i < 20; i++)
  17.     *value(dap, i) = i * 3;
  18.   for(i = 0; i < 20; i++)
  19.     printf("stack[%d] = %d, heap[%d] = %d\n",
  20.          i, *value(&da,i), i, *value(dap, i) );
  21.   /*  *value(dap, 20) = 100; */ /* a test of the error system */
  22.   /* must always remember to clean up! */
  23.   release_heap_array(dap);
  24.   free_array(&da);
  25. }