← Back to STL Containers
Question 517
Undo Text Editor
Undo Text Editor
Write a program that simulates a tiny text editor with undo. Read commands from standard input until the input ends. Each command is on its own line and is one of: -add WORD— push WORD (a single word with no spaces) onto astack<string>-undo— remove the most recently added word; if there are no words, do nothing -(empty)Only
Expected Output:
hello world hello (empty) a b
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
STL ContainersStacks
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.