Name: Anonymous 2008-12-02 20:12
This C++ code is causing a segfault, and I can't understand why. Yes, it's homework, but I don't want my homework done. I just want the one bug that's pissing me off and that I can't fix fixed. You'd think it's the pointer fucking up, but apparently not. Here's the code causing the issue, with printf's to figure out where the hell it's fucking up:
printf("attempting get next\n");
list = list->getNext();
list->print();
printf("attempting remove previous\n");
list->removePrevious();
printf("success!\n");
The list->print(); is to ensure that the pointer's pointing at something of value. This is never what actually fucks it up, so apparently the pointer's not pointing off into nowhere.
Here's the code for removePrevious(), again with debugging printf's:
printf("deleting previous");
previous->setPrevious(NULL);
previous->setNext(NULL);
delete previous;
printf("...done\n");
previous == NULL;
It never actually prints out "deleting previous". It evidently segfaults right when it tries to call removePrevious().
printf("attempting get next\n");
list = list->getNext();
list->print();
printf("attempting remove previous\n");
list->removePrevious();
printf("success!\n");
The list->print(); is to ensure that the pointer's pointing at something of value. This is never what actually fucks it up, so apparently the pointer's not pointing off into nowhere.
Here's the code for removePrevious(), again with debugging printf's:
printf("deleting previous");
previous->setPrevious(NULL);
previous->setNext(NULL);
delete previous;
printf("...done\n");
previous == NULL;
It never actually prints out "deleting previous". It evidently segfaults right when it tries to call removePrevious().