These are the instructions for my c program. I keep getting started then it never seems to work please help! Instructions below. Thanks in advance.
Write a C program that reads a sentence (i.e. unknown number of characters ending with a period '.') and prints each word in the sentence on a separate line. The program should also print the length of each word. At the end, it will print the number of characters in the longest word. The sentence must start with a non-blank character and each word must be separated with exactly one blank character. (For this program a word is a sequence of any non-blank characters). There shouldn’t be any spaces between the last word and the period that ends the sentence. Your program should read the sentence one character at a time.
Your program must include a function called read_and_count(), that reads a single word, prints the word and the number of characters, and returns the number of characters. (Hint: The function should continue reading and printing characters one by one until it reads a blank (‘ ‘) or a period (‘.’). Then it should print and return the count to the main function. You must think of a way of how to inform the main function when the last word is read and printed). Your main program should call the function read_and_count() properly so that it can use the value that the function returns to find the number of characters in the longest word.
Output Specification:
Sample Run:
Type the sentence: What a lovely day.
Output:
What 5 characters.
a 1 character.
lovely 6 characters.
day 3 characters.
The longest word in the sentence is 6 characters long