I want to write a function that gets a pointer to the title of a linked list and removes every second member from the list. A list is a related element of an element of type:
typedef struct element{ int num; struct element* next; }element;
I am new to all of these arithmetic pointers, so I'm not sure if I am writing them correctly:
void deletdscnds(element* head) { element* curr; head=head->next; //Skipping the dummy head// while (head!=NULL) { if (head->next==NULL) return; else { curr=head; head=head->next->next; //worst case I'll reach NULL and not a next of a null// curr->next=head; } } }
I constantly changed it, as I continued to find errors. Could you point out possible errors?
Jozef source share