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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.