I'm having troubles getting the read to work.
I feel this should work.
It doesn't get past the anoted location below.
[Edit]
What I'm trying to do is read into my linked list.
I used the regular ifstream, but it doesn't work.
It isn't geting past the while loop. As if the condition never is proven true.
[/Edit]
[Edit]Code:void linklist::read() { initializeData(); ifstream instream("members.dat",ios::in); if (!instream) cout << "File could not be opened\n...."; else { link *current; current = head; while (current != tail) //******Doesn't get past here. {cout<<"test";instream >> buffer1; cout<<buffer1; for(x=0;x<count1;x++) { current->fname[x]=buffer1[x]; } for(x=0;x<count2;x++) { instream >> current->lname[x]; } for(x=0;x<count3;x++) { instream >> current->ssnumber[x]; } instream>>current->age; instream>>current->weight; current = current->next; } } }
I've fix at least part of my read, but it still doesn't work correctly.
below is the updated code. It just hangs and doesn't do anything when ran.
[/Edit]
Code:void linklist::read() { initializeData(); ifstream instream("members.dat",ios::in); if (!instream) cout << "File could not be opened\n...."; else { link *current; link* newlink=new link; current = head; while (!instream.eof()) // { instream >> buffer1[x]; for(x=0;x<count1;x++) { newlink->fname[x]=buffer1[x]; } instream>>buffer2[x]; for(x=0;x<count2;x++) { newlink->lname[x]=buffer2[x]; } instream>>buffer3[x]; for(x=0;x<count3;x++) { newlink->ssnumber[x]=buffer3[x]; } instream>>age; newlink->age=age; instream>>weight; newlink->weight=weight; current = newlink->next; } } }



LinkBack URL
About LinkBacks



.