blob: 45c4eef66e0bc245ca2ea8a53b794aaed7627d00 (
plain) (
tree)
|
|
#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;
}
|