Tail works on stdin, too.  Can't mmap that.  The usual way is to
buffer the last N lines read in a ring buffe.r

On Aug 14, 4:22 pm, Prem Mallappa <prem.malla...@gmail.com> wrote:
> Tail by default displays last 10 lines of file.
>
> 1. mmap the file
> 2. keep two pointers(A, B) pointing to beginning of the file
> 2. search for 10th "\n" using B, if not found i.e file has less than
> 10 lines, print from beginning to end
> 3. if found, start incrementing both A and B to the next "\n". untill
> B reaches end of file.
> 4. Print from A till end of file.
>
> On 13 Aug, 23:13, amit <amitjaspal...@gmail.com> wrote:
>
>
>
> > I am trying using fseek but somehow its not working?

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to