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

Using C++ How do I print this unsorted list code to a file called outfile1.txt?

ID: 3799068 • Letter: U

Question

Using C++

How do I print this unsorted list code to a file called outfile1.txt?

//----------------------------------------

//             PrintList

// Non-member function to print list of items

//----------------------------------------

        else if (command == "PrintList")

        {

          cout << " These are the List values" << endl;

          outFile << " These are the List values" << endl;

          PrintList(list);

        }

// Or how do I use this code to print the unsorted list to a file called outfile.txt?

void PrintList(UnsortedType &list)

{

int length;

ItemType item;

ItemType data;

list.ResetList();

length = list.GetLength();

for (int counter = 1; counter <= length; counter++)

{

    item = list.GetNextItem();

    item.Print();

    cout << endl;

}

cout << "Length of list = " << length << endl << endl;

}

Explanation / Answer

Please check this code by puuting this function in your main, now you can output your unsorted list in a file named outputfilr1.txt. You need to put the variable containing unsorted list and club that into the code given in bold.

//----------------------------------------

//             PrintList

// Non-member function to print list of items

//----------------------------------------

        else if (command == "PrintList")

        {

          cout << " These are the List values" << endl;   

          PrintList(list);

        }

// Or how do I use this code to print the unsorted list to a file called outfile.txt?

void PrintList(UnsortedType &list)

{

int length;

ItemType item;

ItemType data;

list.ResetList();

length = list.GetLength();

for (int counter = 1; counter <= length; counter++)

{

    item = list.GetNextItem();

    item.Print();

    cout << endl;

}

cout << "Length of list = " << length << endl << endl;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote