title: Read last line of a text file - C programming
body: <p>I'm still a novice in C as I just started out. Here is a part of my function to open the file and then save the file lines into variables. I did while to loop until the end of file so I can get the last line, however it did not go as expected. So, I was wondering how can I get just the last line from a text file? Thank you.</p>
  
  <pre><code>    tfptr = fopen("trans.txt", "r");
      while (!feof(tfptr)){               
              fscanf(tfptr, "%u:%u:%.2f\n", &amp;combo_trans, &amp;ala_trans, &amp;grand_total);                                              
      }
      fclose(tfptr);  
  </code></pre>
  
  <p>sample text file:</p>
  
  <pre><code>0:1:7.98
  1:1:20.97
  2:1:35.96
  2:2:44.95
  2:2:44.95
  3:2:55.94
  </code></pre>