struct cell { char* word; cell* next; cell(char* w, cell* nxt) { word = strnewdup(w); next = nxt; } };where function strnewdup(w) uses the new operator to allocate memory, copies w into that new memory and returns a pointer to the new memory. (You will need to write strnewdup.)
Implement the following functions on lists.
The cat in the hat hit the ratthen the output should be
The cat hat hit in rat theThe name of the input file should be read from the user.
Words are defined as for assignment 8. That is, anything that the >> reads as a string is considered a word. A word that begins with a capital letter is not the same as a word that begins with a lower case letter. For example, "The" and "the" are considered different words for this assignment.
Use linked lists to implement this assigment. Keep a list of all words read so far. When you read a word, check whether it is already a member of the list. If so, skip that word. If it is not a member of the list, attach it to the front of the list.
After all words have been read, print a sorted version of the list.