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
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.
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.