pointNode is somehow ending up being NULL, even though head != NULL. Weird. My guess is that you're causing a corruption somewhere (probably in . If I change that line to head->count++ the segfault goes away, but doesn't explain anything. Inspecting the "tree" in the function printWord() the majority of nodes are NULL so... I'm not sure where thoughCode:void buildTree(node* head) { char character; node* pointNode = head; do { character = fgetc(fp); //getchar(); character = tolower(character); //Turns a big letter into a small letter lib <ctype.h> if(character == EOF) { pointNode->count++; // <------------ segfault is here return; }