Question: please answer task 2. task 2 is a modification of task 1, which i have provided picture of below. follow the same language as task

please answer task 2. task 2 is a modification of task 1, which i have provided picture of below. follow the same language as task 1 to complete task 2. please look at task 1 picture and modify it to satisfy task 2. also a guideline is provided for task 2.
Task 2 question  please answer task 2. task 2 is a modification of task
Task 1 code
1, which i have provided picture of below. follow the same language
Task 2 guideline
as task 1 to complete task 2. please look at task 1
heres updated pictures. if you can not view the guideline then ignore the guideline. thank you
task 2 question picture and modify it to satisfy task 2. also a guideline is
task 2 guideline
provided for task 2. Task 2 question Task 1 code 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 ... Ench 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 include #include #include #define BUF_SIZE 1 //set buffer size int main(int args, char *argv[]) 5 6 7 8 char buffer[BUF_SIZE]; 1/open the file , name is sent via command line argument int fd = open(argv[1], O_RDONLY); 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 //check if file was openede successfully if (fd 0) write(1, buffer, BUF_SIZE); //close the file close(fd); exit(); 26 27 Q2 1.open file and read startende 5, 10) int countine: loop af buffer BUF_SZE): Mburoj) count_in loop nrdid, buffer BUF_SIZE) wheSTDOUT_FILENO, bufer, BUF_S2E) buffer) count_line continental 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 mth line to the nth line of the given file. It should have the following syntax: $ ./ body mi fileName The above program displays the contents of the file named fileName, from line m to linen. 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 Q2 1. open file and read start menden im 5. n10) 2 int contine: loop readid, buffer. BUF SIZEX buttoW')count_n Nou Inem) break 3 loop, BUF SZEX write(STDOUT_FILENO, buffer, BUF_S2) butterw) count_line online) break

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!