```
struct ListNode* removeElements(struct ListNode* head, int val) {
struct ListNode *node = head;
while(node)
{
if(node->val == val)
{
node->val = node->next->val;
node->next = node->next->next;
free(node->next);
}
else
node = node->next;
}
return head;
```

}