title: c write the string to file line by line
body: <p>fwrite don't work, what's wrong with my code? </p>
  
  <pre><code>void printTree (struct recordNode* tree) {
          char* report1;
  
          FILE *fp = fopen("test.txt","w");
  
          if (tree == NULL) {
            return;
          }
          //if(fp) {
  
            counter2++;
            printTree(tree-&gt;right);
  
            fwrite(fp,"%d\n", tree-&gt;pop);
            //putc(tree-&gt;pop, fp);
  
            //report1 = printf("%s = %d\n");
            printTree(tree-&gt;left);
  
          //}
          fclose(fp);
  
      }
  </code></pre>