I know this has something to do with eof, but I don't know how streams work exactly, i'd understand better if someone could tell me whats going on.
say I have 3 numbers {1, 2, 3} the load function puts the variables into the nodes, but when I go to print all the nodes only 1 will print.
void load() {
ifstream fload;
node *n = new node;
node *temp = new node;
fload.open("DoubleList.dat");
if(fload){
fload >> n->data;
n->next = NULL;
n->prev = NULL;
head = n;
tail = n;
curr = n;
while (!fload.eof()) {
fload >> temp->data;
temp->next = NULL;
temp->prev = curr;
curr = temp;
tail = temp;
}
}
}
Aucun commentaire:
Enregistrer un commentaire