Question: Using onlinegdb.com, please explain how to get the outputs, and please show screenshots of how to get the output, I have the code below, i

Using onlinegdb.com, please explain how to get the outputs, and please show screenshots of how to get the output, I have the code below, i just do not know how to get the outputs needed.
What to do?
Write a C program mywrite whose behavior resembles that of the system command write.
mywrite accepts the following parameters:
$ mywrite terminal
where text messages are being sent to another terminal.
mywrite operates by copying lines from stdin of your terminal to stdout of the username's terminal.
Every line typed by the sender must be displayed at the receiver's terminal immediately after the sender
presses the Enter key or closes the connection.
The first line to be displayed on the other terminal must include a greeting message similar to this:
Message from another terminal...
When the user who started mywrite presses Ctrl-D (EOF), mywrite closes the connection and displays
the final message on the other terminal:
mywrite must implement a filtering mechanism based on the following list of keywords: apple, pear,
banana, plum. If one of these keywords appear as a part of the input line, mywrite will produce a
relevant warning on the sender's terminal and will not send that line to the receiver. Here's an example of
an input line and a corresponding warning:
I like bananas!
You entered a prohibited word: banana. Your message will not be sent.
What to submit?
A single C source code file with your work.
Several screenshots (in PNG or JPG format) showing two parallel terminal sessions with mywrite
message exchange.
code:
#include
#include
#include
#include
#include
#define MAXLINE 1024
// List of prohibited keywords
const char *keywords[]={"apple", "pear", "banana", "plum"};
const int keyword_count =4;
// Function to check if a message contains a prohibited word
int contains_prohibited_word(const char *message){
for (int i =0; i keyword_count; i++){
if (strstr(message, keywords[i])!= NULL){
return 1;
}
}
return 0;
}
int main(int argc, char *argv[]){
if (argc !=2){
fprintf(stderr, "Usage: %s terminal
", argv[0]);
exit(1);
}
// Open the target terminal for writing
int fd = open(argv[1], O_WRONLY);
if (fd ==-1){
perror("open");
exit(1);
}
char buffer[MAXLINE];
printf("Message from another terminal...
");
// Read lines from stdin and write to the terminal
while (fgets(buffer, MAXLINE, stdin)!= NULL){
if (contains_prohibited_word(buffer)){
fprintf(stderr, "You entered a prohibited word. Your message will not be sent.
");
} else {
if (write(fd, buffer, strlen(buffer))==-1){
perror("write");
close(fd);
exit(1);
}
}
}
// Close the connection when EOF is encountered
printf("Connection closed.
");
close(fd);
return 0;
}
 Using onlinegdb.com, please explain how to get the outputs, and please

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!