I am inserting elements after a element in a linked list but my code is not running.
typedef struct Node
{
int info;
struct Node *next;
struct Node *prev;
}node;
node *head;
// w-the element to be inserted & z-the position after which it has to inserted
void insertpos(int w,int z)
{
int i;
node *ptr=head;
node *ptr1;
for(i=1;i<=z-1;i++)
{
ptr=ptr->next;
}
ptr1=(node*)malloc(sizeof(node));
ptr1->info=w;
ptr->next=ptr1;
((ptr->next)->next)->prev=ptr1;
}