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 >
Wrap
C/C++ Source or Header
|
1991-03-02
|
789b
|
25 lines
/********* Listing 3 ********************** TESTARRY.C ****
* TESTARRY.C : Test the dynamic_array
* (c) C Gazette, see Listing 1 for usage.
*********************************************************/
#include "array.h"
#include <stdio.h>
void main()
{
int i;
dynamic_array da, *dap;
create_array(&da, 20);
for(i = 0; i < 20; i++)
*value(&da, i) = i * 2; /* assign a value to each element */
dap = make_heap_array(20);
for(i = 0; i < 20; i++)
*value(dap, i) = i * 3;
for(i = 0; i < 20; i++)
printf("stack[%d] = %d, heap[%d] = %d\n",
i, *value(&da,i), i, *value(dap, i) );
/* *value(dap, 20) = 100; */ /* a test of the error system */
/* must always remember to clean up! */
release_heap_array(dap);
free_array(&da);
}