Question
Write a C program in a file called noVowels2.c to classify words as noVowel matches as specified below. Input: The input comes from stdin and
Write a C program in a file called noVowels2.c to classify words as noVowel matches as specified below.
Input:
The input comes from stdin and consists of a sequence of strings separated by white space. This means the strings may be on one line or on multiple lines.
Behavior:
Your program should read in a sequence of words from the input stream, group them into sets where each set consists of words that are noVowel matches of each other, and print out the resulting words one group per line as specified below. Multiple occurrences of a word in the input should be retained, i.e., the total number of legal words in the output should be the same as the total number of words in the input. For the purposes of this program, a word is a sequence of alphabetic characters. The property of being a noVowel match is case-insensitive. Note that it is possible if a word is all vowels. In this case your program should ignore this word. It is not an error, but it should not appear in the list of groupings.
Output:
The output from your program should be printed out as follows (see example below):
o each group of noVowel matches should be printed out on a separate line;
o The order of the noVowel match groups should be the same as the order they appear in the input. In other words, if dog is the first word input, then the first line of the output should be all the noVowel matches of dog that appear in the input. So each line will include all the words that are noVowel matches of each other. The order of the words per line should also be the order in which they appear in the input. Also, although case should not be considered when determining if words are noVowel matches of each other, when printing out the words the original case (the case of the words in the input) should be preserved. In other words, if a word appears as WoRd in the input, it should be printed out as WoRd.
Assumptions:
You may assume that each word has length at most 64, though your program should still protect against buffer overflow if a word longer than 64 chars is entered.
Error Conditions:
A string that contains something other than an alphabetic character is an error. When such strings are found in the input, an error message should be printed, the string should be ignored, and the next string would then be read in.
Restrictions:
The point of this problem is to get experience using malloc() or calloc() to create linked structures. Therefore you may NOT use an array where you allocate some large amount of space for your list of words, perhaps reallocating more space as necessary. Instead you should use a linked list or similar structure that uses exactly the amount of memory you need. I'm not saying you can't use arrays in your assignment. You certainly will need an array to fit the longest possible word to use with scanf(). You are allowed to use static arrays in the program as you need them, but you must use a linked list to store your list of noVowel equivalence groups and the list of words within those groups. See the comment section below. Also, rather than include in your structs a large array to save the largest possible word, include an char * and allocate exactly the amount of memory you need. The Arrays, Ptrs, Structs deck has an example program that reads words and stores them in a linked list. Look over that example if you're confused.
Example:
Given the list of words
Hat mast past hit mostly Past
hoot prove Pest HATE prove paste most
the output generated should be as follows:
Hat hit hoot HATE
mast most
past Past Pest paste
mostly
prove prove
Comment: A good data structure for this program is a linked list for the group of noVowel matches, each node of which contains a linked list of the strings for each of those matches. In other words, use two different node types. One for the set of matches, and another to hold the actual words input.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started