title: Binary tree only displays half of content
body: <p>My program is suppose to read characters from a file and display the pre-order, in-order, and post-order traversal of the content in the file. The issue is that it only displays half the content in the file. Not sure where and why it stops reading from the file?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #define MaxWordSize 50
  
  typedef struct {
      char word[MaxWordSize + 1];
  }NodeData;
  
  typedef struct treeNode {
      NodeData data;
      struct treeNode *left, *right;
  }TreeNode, *TreeNodePtr;
  
  typedef struct {
      TreeNodePtr root;
  }BinaryTree;
  
  void visit(TreeNodePtr node) {
      printf("%s", node -&gt; data.word);
  }//end visit
  
  void preOrder(TreeNodePtr node) {
      void visit(TreeNodePtr);
      if (node != NULL) {
          visit(node);
          preOrder(node -&gt; left);
          preOrder(node -&gt; right);
      }
  }
  
  void inOrder(TreeNodePtr node) {
      void visit(TreeNodePtr);
      if (node != NULL) {
          inOrder(node -&gt; left);
          visit(node);
          inOrder(node -&gt; right);
      }
  }
  
  void postOrder(TreeNodePtr node) {
      void visit(TreeNodePtr);
      if (node != NULL) {
          postOrder(node -&gt; left);
          postOrder(node -&gt; right);
          visit(node);
      }
  }
  
  TreeNodePtr buildTree(FILE *in) {
      char str[MaxWordSize + 1];
      fscanf(in, "%s", str);
      if (strcmp(str, "@") == 0) {
          return NULL;
      }
      TreeNodePtr p = (TreeNodePtr)malloc(sizeof(TreeNode));
      strcpy(p -&gt; data.word, str);
      p -&gt; left = buildTree(in);
      p -&gt; right = buildTree(in);
      return p;
  }
  
  int main() {
      TreeNodePtr buildTree(FILE *);
      void preOrder(TreeNodePtr);
      void inOrder(TreeNodePtr);
      void postOrder(TreeNodePtr);
      FILE *in = fopen("./c/btree.in.txt", "r");
      BinaryTree bt;
      bt.root = buildTree(in);
      printf("\n The pre-order traversal is : ");
      preOrder(bt.root);
      printf("\n The in-order traversal is : ");
      inOrder(bt.root);
      printf("\n The post-order traversal is : ");
      postOrder(bt.root);
      printf("\n\n");
      fclose(in);
      system ("PAUSE");
      return 0;
  }
  </code></pre>
  
  <p>My input file content is:</p>
  
  <pre><code>C E F @ @ H @ @ B @ @ G A @ @ N J @ @ K @ @
  </code></pre>
  
  <p>My output is:</p>
  
  <pre><code>The pre-order traversal is: CEFHB
  The in-order traversal is: FEHCB
  The post-order traversal is: FHEBC
  </code></pre>