summaryrefslogblamecommitdiffstats
path: root/test/tsearch.c
blob: 45c4eef66e0bc245ca2ea8a53b794aaed7627d00 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15














                                                                                                    
#include <stdio.h>
#include <search.h>
#include <string.h>
#define CAST (int (*) (const void *, const void *))
int compar (const char * a, const char * b) {
	return strcmp(a, b);
}
int main () {
	void * root = NULL;
	tsearch("key1", &root, CAST compar);
	tsearch("key1", &root, CAST compar);
	tsearch("key2", &root, CAST compar);
	fprintf(stdout, "this should say key1: %s\n", *(char **) tfind("key1", &root, CAST compar));
	return 0;
}