Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

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