I want to add a Newnode to the end of a list but it crashes and goes into a endless loop. I am attaching the function: hope to your help!!
void AddProduct(products **head,products *newProduct)
{
products* current=*head;
if(current == NULL)
{
(*head) =(products *)malloc(1*sizeof(products));
(*head) = newProduct;
current=*head;
return;
}
while(current->nextProduct!=NULL)
{
current=current->nextProduct;
}
//Attaching the new product to the list
current->nextProduct=newProduct;
newProduct->prevous=current;
//SortList(head);
}