Question: 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.

#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");
}
}
} 
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
Get step-by-step solutions from verified subject matter experts
