Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions