Question: C Programming Question The purpose of this program is to extract all words from input, where we will consider a word to be any sequence
C Programming Question The purpose of this program is to extract all words from input, where we will consider a word to be any sequence of letters, lowercase or uppercase. Program must read the standard input and write to the standard output. For example, if the input file looks as follows :
This is the first line. Numbers14are-ignored.
The output must be: This is the first line Numbers are ignored
Implementation: The program must use the getchar and putchar functions to copy input characters to the output. Do not use arrays to save characters. Program should read character by character and if needed, print them out as soon as they are read. The program should simulate a state machine in the following way: You should have an integer variable named state, that would initially have value 0, and it would change values as follows. If state==0 it means that we are waiting for a word. If the input character read is not a letter, then we should ignore it and keep reading. If the input character is a letter, then we should print it, and change state to 1. If state==1 it means that we are in the middle of a word. If the next input character is a letter, we should print it and not change state. If the next input character is not a letter, we should print a newline character and change state to 0.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
