Question: write this program using the C language please comment which each statement does use the following structure: typedef struct word_ { char word[10]; struct word_*
write this program using the C language
please comment which each statement does
use the following structure: typedef struct word_
{
char word[10];
struct word_* nextWord;
struct word_* lastWord;
} Word;
you will be impementing the undo and redo functionality, although it will be clunky. you will input a word at a time to form a sentence, then have the option to undo and redo the last word put it. you will only have to redo the last word that is undone. this functionality is in the form of a stack.
Function Prototypes
Word* addWord(Word* lastWord, Word* newWord);
this function will adds the newest word to the stack of words the last word passed into this function is the top of the stack. return the newest top of the stack after
void printSentence(Word* lastWord);
prints out the sentence as one would read it. be careful the last word (the top of the stack) is the parameter to this function
void freeSentence(Word* lastWord);
frees every word in the sentence
Word* undoWord(Word** lastWordPtr);
takes out the last word entered from the stack and returns it. update the new stack after
sample output
1: add word
2: undo
3: redo
4: quit
option: 2
nothing to undo
nothing to print
1: add word
2: undo
3: redo
4: quit
option: 1
enter your word: This
This
1: add word
2: undo
3: redo
4: quit
option:1
enter your word: is
This is
1: add word
2: undo
3: redo
4: quit
option:2
This
1: add word
2: undo
3: redo
4: quit
option:3
This is
1: add word
2: undo
3: redo
4: quit
option:4
Exiting...
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
