Write a program that inputs a line of text from the user and

Write a program that inputs a line of text from the user and then prints it out again with all instances of the letter \"e\" changed to \'3\'. So, for example, if a user enters \"Here is a line\" then the program should print \"H3r3 is a Iin3\". Your program should use pipes and a child process to do work as follows: The process should start by creating a child. The parent should input a string from the user The parent should send that string to the child. The child should convert the string and send it back The parent should print the converted string Signals Write a program that, upon receiving SIGTERM, prints the message \"Thank you, I will now terminate\" and then quits. Fork/Exec/Pipes Write a program that inputs a single line from the user and then prints the number of words in the line. It should determine the number of words by using fork/exec with the command \"wc - w\". Hard Signals In this problem you will design an electronic safe program where the secret combination is entered as a series of signals. When the correct sequences of signals is received, it should print \"You know the secret code!\" The secret code is SIGSTOP, SIGTERM, SIGSTOP, SIGHUP. After the program receives those signals, in that order, it should print the message. Write a program that prints out the number of files in the current directory. Your program should use fork and exec to execute the equivalent shell command \"Is | wc -1\". After running the commands, the program should output the number of lines in the following format: There are 8 files 1n the current directory.

Solution

Normal:

We can use tr command along with read command & pipe to read input from the user and translate the \'e\' to \'3\'.

So the command would be:

Signal:

The handler code would be:

printf(\"Thank you, I will now terminate\ \"); exit(0); default: fprintf(stderr, \"Error: Handler not found \ \"); return;

}

}

switch (signal) {
case SIGTERM:

printf(\"Thank you, I will now terminate\ \"); exit(0); default: fprintf(stderr, \"Error: Handler not found \ \"); return;

}

}

 Write a program that inputs a line of text from the user and then prints it out again with all instances of the letter \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site