Thread: writing a program called tail like the one in unix

  1. #1
    Registered User
    Join Date
    Oct 2001

    Cool writing a program called tail like the one in unix

    Hi can someone help me. I have to write a program called tail that will read lines from a file until it comes to the EOF, then the program should print out the last n lines of input. Its similar to the tail in unix. Thanks

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    #include <stdio.h>
    #include <stdlib.h>
    int main ( void )
       char buf[1024]={0};
       sprintf( buf, "tail %s %s", argv[1], argv[2] );
       system( buf );
       return 0;
    It doens't get much simpler than that. Seriously, post your code. Read the god damn homework post and the FAQ.


  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Have you figured out how to implement the opposite command 'head', to print out the first 10 lines of a file?

    It doesn't take much to get from one to the other.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  2. Replies: 1
    Last Post: 12-10-2005, 11:25 AM
  3. writing a grep program
    By cnovice in forum C Programming
    Replies: 8
    Last Post: 11-22-2005, 08:05 AM
  4. Writing a program, need some help.
    By ChrisH in forum C Programming
    Replies: 4
    Last Post: 12-01-2004, 03:54 PM
  5. Remotely accessing an NT PC from a Unix C++ program
    By bhorrobi in forum C++ Programming
    Replies: 0
    Last Post: 10-01-2001, 09:42 AM