Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: sunnycoderPosted on 2006-05-20 at 21:01:05ID: 16726722
front=front->next; /* front moves to next member in queue */
>>>>>>> you moved fromt to next node
if(front==NULL)
rear=NULL; /* rear also changes if there was only one value in queue */
else
front->next=NULL;
>>>>>>>>>>> here you set its next to NULL !!!!!!!
int dequeue()
{
node *temp;
int delval;
if(front==NULL)
return -999;
temp=front;
front=front->next; /* front moves to next member in queue */
if(front==NULL)
rear=NULL; /* rear also changes if there was only one value in queue */
temp->next=NULL; // this will not be in else .. you should delink the reference anyway
delval=temp->val;
free(temp); /* memory free */
return delval; /* deleted value returned */
}