Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!