I have a user-defined class Character, of which fighting is a member of type Character. Within the destructor, I have the following code:
Character *dp = new Character;
while(fighting!=NULL) // erase this linked list
dp = fighting;
fighting = fighting->next;
dp->next = NULL;
This works, until fighting gets the hex value of 0xdddddddd (I checked in the MSVC++ debugger). It goes through the loop and tries to dereference a NULL pointer when this occurs. How can I make this so that it doesn't go through the loop when fighting == NULL or 0xdddddddd? I tried the corresponding C++ code, but it says there is no operator that can convert from Character * to int (it may have said unsigned long, but I know it was an int). Any help is appreciated.