int main(int argc, char *argv[]) { char tmpfile[80]; char key[ZKYLEN]; int status,val; BTA *dict; sprintf(tmpfile,"/tmp/bt_%d",getpid()); btinit(); if ((dict = btcrt(tmpfile,0,FALSE)) != NULL) { unlink(tmpfile); while (fgets(key,ZKYLEN,stdin) != NULL) { if (strrchr(key,'\n') != NULL) key[strlen(key)-1] = '\0'; status = binsky(dict,key,0); if (status != 0) { print_bterror(); exit(EXIT_FAILURE); } } btpos(dict,ZSTART); while (bnxtky(dict,key,&val) == 0) puts(key); } else { fprintf(stderr,"Unable to open temp btree index.\n"); } btcls(dict); return EXIT_SUCCESS; }
void add_data_to_tree(BTA *t,person* arr,int size){ if(t == NULL){ fprintf(stderr,"NULL value error %s:%d!!1\n",__FILE__,__LINE__); exit(1); } int i; for(i = 0;i < size; i++){ binsky(t,arr[i].name,arr[i].tel); } }