Question
Below is the code for the problem. Complete it as necessary. #include #include using namespace std; struct Node { int data; Node* next; }; const
Below is the code for the problem. Complete it as necessary.
#include
#include
using namespace std;
struct Node
{
int data;
Node* next;
};
const string FILENAME = "/home/fac/sreeder/class/cs2430/lab2.dat";
void insertInOrder(Node*& h, int d);
// inserts d into h in numerical order
// post: h may be changed
void printList(Node* h);
// prints all data on h to the screen in a column
void delList(Node*& h);
// post: each node of h deleted
int main()
{
Node* head = nullptr;
ifstream inFile;
int num;
inFile.open(FILENAME);
if (inFile.fail()){
cout
cin.get();
}
while (inFile >> num)
insertInOrder(head, num);
inFile.close();
cout
printList(head);
cout
delList(head);
return 0;
}
void insertInOrder(Node*& h, int d)
{
// complete this function
}
void printList(Node* h)
{
// complete this function
}
void delList(Node*& h)
{
// complete this function
}
lab2.dat Write a short program in C++ that accomplishes the following: 1) Contains a node for a linked list that can store a single piece of integer data, along 17 78 with the pointer to the next node. 2) Reads the file "lab2.dat" from the class - create a constant string for this 3) While reading the file, inserts the integers into a linked list in numerical order (from smallest to largest). Be sure to close the file when you are done reading. 4) Prints the finished list in a column to the screen. 5) Deletes all nodes in the list before ending the program. Three functions are recommended: "insert in order", "prit", "delete list". There are no 137 0 45 32 1 6 classes to be created for this assignment. 12 19 78 86 4Step 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