Question: C language Write a C program that displays a prompt on the screen (with character '$), reads a string from the user, and displays the
Write a C program that displays a prompt on the screen (with character '$), reads a string from the user, and displays the exact same string when the user presses Enter. This process is repeated in an infinite loop, until the user kills the program by pressing Control+C. In order to read the string from the keyboard, use function fgets and pass stdin as its last argument, indicating that the standard input (keyboard) is the device from which the string should be read. Use the man pages to obtain full information about this function. Notice that fgets will keep the newline character (' ') introduced when pressing the Enter key at the end of the string. Get rid of it by replacing it with a null character ('). Punction strlen will be useful here. Here is an example for the program output: main $ hello hello $ how are you how are you $ C Control+C was pressed, program killed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
