440 Intermediate C Programming
freque ncies [ ind ]. freq );74
ListNode * ln = L istNod e_crea te ( tn) ;75
head = List_i nsert ( head , ln , SORTED ) ;76
ind ++;77
}78
return head ;79
}80
void List_pri n t ( L i stNode * head )81
{82
i f ( head == NULL )83
{84
return ;85
}86
Tree_pr i nt ( head -> tnptr , 0) ;87
List_pr i nt ( head -> next );88
}89
// utility .h1
#i f n d e f UTILITY_H2
#d ef in e UTILITY_ H3
#in clude < stdio .h >4
// write one bit to a file5
6
// whichbi t indicat e s which bit this is written to (0 means7
// leftmost , 7 means right m ost )8
// curbyte is the c u r rent byte9
//10
// if whichbit is zero , curbyte is reset and bit is put11
// to the leftmost bit12
//13
// when which bit r e a ches 7, this byte is written to the14
// file and whichbit is reset15
//16
// the functi o n returns 1 if a byte is written to the file17
// returns 0 if no byte is written18
// -1 if it tries to write and fails19
int writeBit ( FILE * fptr , unsigned char bit ,20
unsigned char * whichbit , unsigned char *21
curbyte ) ;22
// if * w hichbit is not 0, some bits of * curbyte are not used23
// fill these bits by 0 and write the byte to the file24
int padZero ( FILE * fptr , unsigned char * whichbit ,25
unsigned char * curbyte );26
27
int readBit ( FILE * fptr , unsigned char * bit ,28
unsigned char * whichbit ,29
unsigned char * curbyte );30
#e ndif31
// utility .c1
#in clude < stdio .h >2