File reading using (head & tail)

I have a task to do within one week. I tried to solve it but I did not get the perfect solution.

The task is to read a command line arguments the consists of (progName fileName linesToRead startPosition) OR (progName fileName).The programs should open the file provided then it should read it for number of linesToRead(i,e: prog test.txt -3) the program should read the first three lines only, similarly for tail. It should read three lines from the bottom of the file.

Pleae if you have any clue for solving such a problem reply to this message as soon as possible.

Thanks in advance

Abdul Hameed

Comments

: Hi all: : I have a task to do within one week. I tried to solve it but I did not get the perfect solution.: : The task is to read a command line arguments the consists of (progName fileName linesToRead startPosition) OR (progName fileName).: The programs should open the file provided then it should read it for number of linesToRead(i,e: prog test.txt -3) the program should read the first three lines only, similarly for tail. It should read three lines from the bottom of the file.: : Pleae if you have any clue for solving such a problem reply to this message as soon as possible.: : Thanks in advance: : Abdul Hameed:

You didn't mention any problem, only a task. Do the task and then post the problems you encounter with it.

If you want to do something similar to tial, then look at the source for tail.