Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have a linked list assignment. It\'s a simple text editor that will go through

ID: 673322 • Letter: I

Question

I have a linked list assignment. It's a simple text editor that will go through the list from a file and be able to insert and delete. I have 95% of the program done, the only trouble I am having is reading the file.

int main()
{
   char choice;
   int linNo;
   listTextEditor command;
   startList = NULL;
   int linPos;
   ifstream inRFile;
   char *text;

   inRFile.open("CS216PA2.txt");

   while(inRFile>>linPos>>text)
   {
       command.insertLineFromFile(text);
   }

It keeps telling me that my char *text; is not being initialized and won't run through the while loop.

Explanation / Answer

int main()
{
   char choice;
   int linNo;
   listTextEditor command;
   startList = NULL;
   int linPos;
   ifstream inRFile;
   char *text;

{

taxt = "this is text";

}

   inRFile.open("CS216PA2.txt");

   while(inRFile>>linPos>>text)
   {
       command.insertLineFromFile(text);
   }

or