Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


geoteamy

Member Since 13 Nov 2012
Offline Last Active Nov 13 2012 12:50 PM

Topics I've Started

wierd linked list deletion problem

13 November 2012 - 12:52 PM

I am having a weird problem were i have a linked list system that creates objects and it works fine until i add any numeric variable to the main loop then it crash when it is deleting the objects


while (1)//this deletes the objects
	{
		if (root->next != NULL)
		{
			temp=root->next;
			delete root;
			root = temp;
		}
		else
		{
			break;
		}
	}


This next part is the beginning of the main loop it works fine until i added the variable "test" after i added it, it crashes whenever i try to delete the whole list using the code above.


int main()
{
	int test = 0;
	zombie master;
	zombie *root = &master;
	zombie *temp=NULL;

PARTNERS