Convert BST to Linked List (segmentation fault)

code: https://ide.codingblocks.com/s/232378

hi @adityakaunhai
you logic and code both are correct
only mistake you have done is
if (root == NULL){
p.head = p.tail = NULL;
}
return p;
this statement comes inside if condition

i hope this help
if your doubt is resolved please mark it as resolved