this code is showing a run error.
here is a link to ide.
Linked list palindrome
Hi keshav
In the while loop in reverse() func
next=next->link causes runtime error as when we are at the last element of list,
initially
cur = last element
prev = second last element
next = null
then
cur = null
prev = last element
next = null -> link which cause segmentation fault i.e. runtime error.
You should use
{
next = cur -> link
curr -> link = prev
prev = cur
cur = next
}
Hope it helps
Give a like and rating if you are satisfied