if(head == NULL)//if head is NULL
{
head = newnode;
head -> link = NULL;
}
else
{
nodetype *current = head;
while( current -> link != NULL)
current = current -> link;
current -> link = newnode;
current -> link -> link = NULL;
}
}
input.close(); //close file
}
}
I can cout the data but got some weird numbers at the backpart like 1053567757. I'm wondering what is that. and i couldn't insert those data back into linked list. Is there any problem with my code ? how to i correct it ? Thanks all for spending some time in my post..
The first problem is the time when you check the error of the read data. Imagine you have just one data set:
You read that data set and everything is fine (not eof). Now you try to read the second non existing data set. The first getline() emits an error but you don't care and store the non existing data.
The solution is that you first read the data and create the node only when there's no error.
The second problem is: This nIC = newnode -> IC; and following overwrite the read data. AGE isn't initialized and so you always get a random number
im using OOP.. using class object. linked list data type. each nodes i saved customer details. but i coulnt read it from txt file. it will appear windows explorer not responding .. not compilation error. i believe that is my linked list there got error. how ? sifu sifu..
I think nvm ba. my assignment gonna due very soon and i need to proceed with documentation. still need prepare for viva. i think i just used save file function will do as backup. the load file i omit. thanks everyone spending your time reading my post. appreciate much