Question: Use C to write a program that: The source process reads information from a file (Therefore, you need to prepare a small text file for

Use C to write a program that:

The source process reads information from a file (Therefore, you need to prepare a small text file for testing purpose).

The source process calls fork() to create the filter process.

The filter process reads information from the source process (passed via an anonymous pipe), converts the uppercase characters to lowercase ones and vice versa, and then prints out the converted characters to the screen.

How to create an anonymous pipe: pipe() API.

**** I attempted the problem, and it is shown in the picture, but it outputs: Segmentation fault (core dumped). I dont know whats wrong****

Use C to write a program that: The source process reads information

#include #include #include #include #include #include #include #include int main (void) char str[1000]; //buffer int ap[2]; //file descriptor FILE *fp; fpopen("text.txt", "r)I/open file int x read (fp, str, 1000); fclose(fp); //close file pid t pipe; I/fork if ((pipe-fork))) /Ichild close (ap[1]) //close writing on first pipe char str[1000]: read (ap[0], str, 1000); I/read string on first pipe intx strlen (str); //convert upper to lower and vice versa for (int = 0; i

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!