Hello, guys i have an irritiating problem in the following function:
void Sort(Point P, Point &AT50, Point &AO50){
Point AT50_new, AT50_last, AO50_new;
while (P != NULL){
if (P->Age <= 50){
AT50_new = new Member;
AT50_new = P;
AT50_new->next = NULL; // <--from here comes the problem
if (AT50 != NULL)
AT50 = AT50_new;
else AT50_last->next = AT50_new;
AT50_last = AT50_new;
}
else
AO50_new = new Member;
AO50_new = P;
AT50_new->next = NULL;// <--from here comes the problem
if (AO50 != NULL)
AO50 = AO50_new;
else AO50_last->next = AO50_new;
AO50_last = AO50_new;
P=P->next;
}
}
The idea of the code is to check every element of a linked list and see if the element have value lower-equal to 50 or higher than 50. After that it has to create two additional lists - one for those lower and equal to 50 and the second for the rest. I spend alot of hours looking at it but i can't find the error i did. If possible could someone find the error and tell me what i did wrong? Thank you in advance!
P.S. Sorry if i'm opening an already disscused threat but i couldn't find any on this topic.