please help C Program Dt Structur3ss class please comment co

please help!! C++ Program D@t@ Structur3ss class

please comment code!

Create all!! Code Using Doubly Linked List

In this project, you should write a simple line editor. Keep the entire text on a linked list, one line in a separate node. Stan the program with entering EDIT tile, after which a prompt appeals along with the line number. If the letter I is entered with a number n following it, then insert the text to be followed before line n. If I is not followed by a number, then insert the text before the current line. If D is entered with two numbers n and m, one n, or no number following it, then delete lines n through m, line n, or the current line. Do the same with the command L, which stands for listing lines. If A is entered, then append the text to the existing lines. Entry E signifies exit and saving the text in a file. Here is an Example: EDIT testfile 1> The first line 2> 3> And another line 4>I 3 3> The second line 4> One more line 5> L 1> The first line 2> 3> The second line 4> One more line 5> And another line//This is now line 5, not 3; 5> D 2//line 5, since L was issued from line 5; 4> L//line 4, since one line was deleted; 1> The first line 2> The second line//this and the following lines 3> One more line//now have new numbers 4> And another line 4> E Good Luck!

Solution

#include <iostream.h>
#include <fstream.h>

typedef struct Node
{
   char charctr[80];
   Node *next, *pre;
}Line;
Line *presentLine;
Line *firstline;
Node *head, *tail;
int col;
void createFirstLine()
{
   Node *p;
   p = new Node;
   presentLine = p;
   head = presentLine;
   tail = presentLine;
   col = -1;
}
void printNewLine()
{
   Node *p;
   p = new Node;  
   p -> next = NULL;
   p->pre = presentLine;
   presentLine->next = p;
   tail = p;
   presentLine=p;
   col = 0;
}
void createNewLine()
{
   Node *p;
   p = new Node;  
   p -> next = NULL;
   if (head == NULL)
   {
       head = p;
       tail = p;
   }
   else
   {
       Node *q = tail;
       q->next = p;
       p->pre = q;  
   }
   tail = p;
   presentLine = p;
}

int main()
{
   cout << \"Enter line: \";
   char line[30];
   cin.getline (line,30);
   ifstream instream;
   instream.open(line);

   char inputRead;
   presentLine = firstline;
   createFirstLine();
   while(instream.read(&inputRead,sizeof(inputRead)))
   {
       if (inputRead == \'\ \')
           printNewLine();
       else
       {
           col++;
           presentLine->charctr[col] = inputRead;
       }
   }
   instream.close();
   return 0;
}

please help!! C++ Program D@t@ Structur3ss class please comment code! Create all!! Code Using Doubly Linked List In this project, you should write a simple line
please help!! C++ Program D@t@ Structur3ss class please comment code! Create all!! Code Using Doubly Linked List In this project, you should write a simple line

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site