Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed
task 1 code
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

How will it be used?

Answered: 1 week ago

Question

how would you have done things differently?

Answered: 1 week ago

Question

3. What information do participants need?

Answered: 1 week ago