Question
Please provide correct c++ code ASAP with outputs please Line Editor = Linked Lists //Complete the line editor program below by implementing all member functions
Please provide correct c++ code ASAP with outputs please
Line Editor = Linked Lists
//Complete the line editor program below by implementing all member functions as instructed.
#include
struct node { string line; node* next, * prev; node() {} node(string s) :line(s) {} };
class editor { private: node* head, * tail; node* current; public: editor() { head = new node; tail = new node; head->next = tail; tail->prev = head; current = head; } void insert(node* newLine, node* before); // insert a new line after
void menu() { system("cls"); cout << "press: "; cout << " i to insert a new line "; cout << " m to insert multiple lines "; cout << " d to delete the current new line "; cout << " c to display the current line "; cout << " g to go line "; cout << " v to view the entire workspace "; cout << " e to erase the entire workspace "; cout << " n to move the current line forward "; cout << " p to move the current line backward "; cout << " l to load a file into workspace "; cout << " s to store the workplace to a file "; cout << " f to find a string "; cout << " r to replace a string "; cout << " x to exit "; } int main() { ifstream fi; ofstream fo; string fname; editor e; char c='.'; while (true) { menu(); //c = _getch(); if (c == 'x') break; switch (c) { case ('i'): cout << "New Line: "; e.readLine(cin); break; case ('m'): e.multipleInsert(); break; case ('d'): e.removeCurrent(); break; case ('c'): e.displayCurrent(cout); break; case ('e'): e.clear(); break; case ('l'): cout << "File Name: "; getline(cin, fname); fi.open(fname); e.load(fi); break; case ('n'): e.forward(); e.displayCurrent(cout); break; case ('p'): e.backward(); e.displayCurrent(cout); break; case ('v'): e.displayAll(cout); break; case ('g'): e.gotoLine(); e.displayCurrent(cout); break; case ('s'): cout << "File Name: "; getline(cin,fname); fo.open(fname); e.save(fo); fo.close(); break; case ('f'): e.find(nullptr); break; case ('r'): e.replace(nullptr); break; } cout << endl << "-----Press a key of your choice or space to continue----- "; c=_getch(); } }
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