//khoi tao cay btree1&2 void init1() { btinit(); if (fopen(data1,"r")==NULL) bt1 = btcrt(data1,0,0); else bt1 = btopn(data1,0,0); //tra ve BTA bt2 = btcrt(data2,0,0); //tra ve BTA }
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; }
int main(){ btinit(); BTA *t; FILE *fin = fopen(CSV,"r"); if(fin==NULL){ fprintf(stderr,"Cannot open file input %s:%d!!!\n",__FILE__,__LINE__); exit(1); } int size = count_line(fin); btcrt(fid,size,0); t = btopn(fid,0,0); //insert data to tree person *new_info = get_data_from_file(fin,size); add_data_to_tree(t,new_info,size); free(new_info); btcls(t); }