/* ** test.c - same as avltree(3) Example 1 */ #include #include "avltree.h" main() { AVL_IX_DESC ix; char buf[1024]; AVL_IX_REC *pe; int ret; pe = (AVL_IX_REC *) buf; avl_create_index(&ix, AVL_COUNT_DUPS, 0); while (gets(pe->key) != NULL) { if (avl_add_key(pe, &ix) != AVL_IX_OK) { fprintf(stderr, "avl_add_key(%s)\n", pe->key); exit(1); } } avl_first_key(&ix); while ((ret=avl_next_key(pe, &ix)) == AVL_IX_OK) printf("%4d %s\n", pe->count, pe->key); if (ret != AVL_EOIX) { fprintf(stderr, "avl_next_key()\n"); exit(1); } exit(0); }