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");
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started