Question: task 2 requires you to modify task 1 code. Ive already provided task 1 code. modify the given code to satisfy task 2 requirements. follow

task 2 requires you to modify task 1 code. Ive already provided task 1 code. modify the given code to satisfy task 2 requirements. follow same language as given code. DO NOT USE PRINTF OR COUT, use only read, write, open, close system calls
task 2 question
 task 2 requires you to modify task 1 code. Ive already
task 1 code
provided task 1 code. modify the given code to satisfy task 2

Task 2 (50 points) Modify the above program to implement a program called body similar to UNIX commands head or tail. It should print from the mh line to the the line of the given file. It should have the following syntax: $/body m n fileName The above program displays the contents of the file named fileName, from line m to line n. Each system call must have error checking, and print an error message if it occurs. You must use open(), read(), write(), and close system calls. 10 points each 1 2 3 4 5 6 tinclude #include #include #define BUF_SIZE 1 //set buffer size int main(int argc, char *argv[]) { char buffer[BUF_SIZE]; 1/open the file, name is sent via command line argument int fd = open(argv[1], O_RDONLY); 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 //check if file was openede successfully if (fd 0) write(1, buffer, BUF_SIZE); 22 23 24 25 //close the file close(fd); exit(); 26 27 }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!