title: Counting the number of lines in a .txt file in c
body: <p>I have a processes.txt file that contains details about incoming processes like so,</p>
  
  <pre><code>0 4 96 30
  3 2 32 40
  5 1 100 20
  20 3 4 30
  </code></pre>
  
  <p>I wanted to find the number of lines in this file. How can that be done?</p>
  
  <p>I tried this code, but it always returns the number of lines as 0</p>
  
  <pre><code>char c;
  int count = 0;
  // fp is the pile pointer
  for (c = getc(fp); c != EOF; c = getc(fp)) 
          if (c == '\n') // Increment count if this character is newline 
              count = count + 1; 
  </code></pre>