Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code given below for Task 1, please modify it for task 2 and answer task 2. Thanks and will rate :) Linux, C programming. #include

Code given below for Task 1, please modify it for task 2 and answer task 2. Thanks and will rate :) Linux, C programming.

image text in transcribed

#include #include #include #include #include

main( int argc, char **argv )

{ int fd,i; char buf[2]; char buf_error_message[20] = "file open error"; fd=open(argv[1],O_RDONLY,0777); if(fd

//write error message

if( write(1, buf_error_message, strlen(buf_error_message))

perror("Error while write system call");

}

}

else

{

while((i=read(fd,buf,1))>0)

{

// display contents

if( write(1, buf, 1)

perror("Error while write system call");

}

}

if(close(fd)

perror("Error while close system call");

}

}

} image text in transcribed

Task Implement a program to display a file's contents. It should be similar to the UNIX cat command when given a single file. Name your command show. It should have the following syntax: Show fileName The above program displays the contents of the file named fileName. 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

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

5 The mechanics of the circular flow model.

Answered: 1 week ago

Question

1 The difference between a command system and a market system.

Answered: 1 week ago

Question

4 How the market system adjusts to change and promotes progress.

Answered: 1 week ago