[Tutor] Trying to extract the last line of a text file
ajkadri at googlemail.com
Thu Oct 19 23:48:57 CEST 2006
Danny.... This is a very clean way to get the last line.
On 10/19/06, Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:
> > first count the number of lines in the file by using a loop. Use a
> > second loop and when teh counter reaches the num_of_lines values: take
> > the line.
> > Is there any other way to do it??
> Yes, there's a way to do it in one pass: you can keep track of the very
> last line you've read from the file at any given time. As soon as you hit
> the end of the file, the auxiliary "last seen line" must be the last line.
To HIM you shall return.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor