Download c source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "array.h"

#define MIN_CNT 10
#define MAX_CNT 20

void print_array(const char* name, array_t* array)
{
	printf("%s =", name);
	for ( size_t index = 0; index < array_get_count(array); ++index )
		printf(" %zu", (size_t)array_get_element(array, index));
	putchar('\n');
	fflush(stdout);
}

int main()
{
	array_t* array1 = array_create(MAX_CNT);
	array_t* array2 = array_create(MAX_CNT);

	srand( (unsigned int)((unsigned long)time(NULL) + clock()) );
	for ( size_t index = 0, count = MIN_CNT + rand() % MAX_CNT; index < count; ++index )
	{
		array_append( array1, (void*)(10 + (size_t)rand() % 90) );
		array_append( array2, (void*)(100 + (size_t)rand() % 900) );
	}

	print_array("array1", array1);
	print_array("array2", array2);

	array_destroy(array1);
	array_destroy(array2);

	return 0;
}