Я вставляю элементы после элемента в связанном списке, но мой код не работает.Вставка после элемента в дважды связанном списке
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;
}
это C++ не C – JerryGoyal
@ Джерри это C – Newbie786
в C не имеют ptr1 = (узел *) таНос (SizeOf (узел)); без структуры. – JerryGoyal