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
:)
Printable View
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
:)
It doens't get much simpler than that. Seriously, post your code. Read the god damn homework post and the FAQ.Code:#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;
}
Quzah.
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.