I have a problem with this code too. right now I have a segmentation fault but before I couldn't get the correct maxValue.
int maxValue(node* head, int max)
{
node* p;
if (head == NULL)
{
return(1);
}
else
{
p = head;
max = p-> item;
while(p != NULL)
{
p = p-> next;
if (p->item > max)
{
max = p-> item;
}
p = p-> next;
}
return max;
}
}