Think I have something that's almost there but when I call it it doesn't seem to output any of the list items.
Code:
void dolatest(string fname, BuckDoubleLinkedList<bookwithposition>& lst)
{
int index = 0; // declare and initialise index
bookobject bo;
ifstream is(fname.c_str(), ios::binary);//open binary input file
int count = 0; // cout used to discover the number of book entries
while (is.read(reinterpret_cast<char *>(&bo), sizeof(bookobject)))
{
bookwithposition bwp(bo); // make book with position
bwp.setPosition(count++); // set position
}
index = count - 5; // set the position to the last five entries
cout << index << endl;
//while we can read a book from the file
while (is.read(reinterpret_cast<char *>(&bo), sizeof(bookobject)))
{
bookwithposition bwp(bo); //make book with position
bwp.setPosition(index++); //set position
lst.insert(bwp); //add to list
}
is.close();//close file when we have done
cout << endl;
}
This is called by...
Code:
void latest(string fname)
{
BuckDoubleLinkedList<bookwithposition> list('a');
dolatest(fname, list); // call function to produce a list
list.printList(); // display the list
system("pause");
}
the dolatest function is adapted from a function which outputs all of the items which works fine. Any help appreciated.