void addLoadEntry(cdStruct* start) { fstream dataFile("output.txt", ios::in); //while(!dataFile.eof()); { cdStruct* newStruct = new cdStruct; cdStruct *newEntry = newStruct; //getnewstruct() getline(dataFile, newStruct->title); getline(dataFile, newStruct->artist); dataFile >> newStruct->numberOfSongs; dataFile >> newStruct->number; cdStruct *ptr = start; while(ptr->next) // while the current entry points to ANOTHER entry ptr = ptr->next; // at this point ptr is a valid entry that points to null so it is the end (or tail) of the list ptr->next = newEntry; ptr->next->next = NULL; } dataFile.close(); }
This post has been edited by JackOfAllTrades: 09 May 2010 - 02:09 PM
Reason for edit:: Added code tags.