title: C: use fwrite to write char to different line
body: <p>I have to write to a file as follows:</p>
  
  <pre><code> A
   B
   C
   D
   ...
  </code></pre>
  
  <p>Each character of the alphabet needs to be written to different line in the file. I have the following program which writes characters one after another:</p>
  
  <pre><code> FILE* fp;
   fp = fopen("file1","a+");
   int i;
   char ch= 'A';
   for(i=0; i&lt;26; i++){
       fwrite(&amp;ch, sizeof(char), 1, fp);
       ch++;
   }
   fclose(fp);
  </code></pre>
  
  <p>How should I change the above program to write each character to a new line. (I tried writing "\n" after each character, but when I view the file using VI editor or ghex tool, I see extra characters; I am looking for a way so that vi editor will show file exactly as shown above).</p>
  
  <p>I tried using the following after first fwrite:</p>
  
  <pre><code> fwrite("\n", sizeof("\n"), 1, fp);
  </code></pre>
  
  <p>Thanks.</p>