ahmed0saber

Undo and Redo in C++

Nov 5th, 2020
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     string current,past="",next;
  6.     int undo_redo;
  7.     cout<<"Enter a text"<<endl;
  8.     cin>>current;
  9.     next=current;
  10.     again:
  11.     cout<<"The current text : "<<current<<endl<<endl;
  12.     cout<<endl<<"If you want to undo , enter 0 ... don't want , Enter 1 ... want to redo , Enter 2 ... want to enter a new text , Enter 3"<<endl;
  13.     cin>>undo_redo;
  14.     if(undo_redo==0)
  15.     {
  16.         next=current;
  17.         current=past;
  18.     }
  19.     else if(undo_redo==2)
  20.     {
  21.         past=current;
  22.         current=next;
  23.     }
  24.     else if(undo_redo==3)
  25.     {
  26.         past=current;
  27.         cout<<"Enter the new text"<<endl;
  28.         cin>>current;
  29.         next=current;
  30.     }
  31.     goto again;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment