Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In c++ how would you copy records from a text file into a doubly linked list. I believe my function to load them to a
In c++ how would you copy records from a text file into a doubly linked list. I believe my function to load them to a doubly linked list works but Im not sure how to set up my main function. load function is as followed:
list::list() { first = NULL; }
void list::load() { item *current; item *prev; ifstream fin; fin.open("List.txt"); prev = NULL; while(!fin.eof()) { current=new item; if (first == NULL) // we set first the first time first = current; fin>>current->name; current->previous=prev; current->next = NULL; if (prev != NULL) prev->next=current; prev = current; // we store the current as the prev for next iteration } fin.close(); }
Step 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