C function that deletes all nodes from a linked list with evenvalues?
The program has to actually free the nodes not just bypassthem.
For example: the input- {2, 2, 2, 1, 2, 2, 7, 9} should return1, 7, 9.
#include <stdio.h>
#include <stdlib.h>
typedef struct node
{
int data;
struct node *next;
} node;
node *create_node(int data)
{
node *ptr = malloc(sizeof(node));
if (ptr == NULL)
{
fprintf(stderr, “Error: Out of memory in create_node()n”);
exit(1);
}
ptr->data = data;
ptr->next = NULL;
return ptr;
}
node *tail_insert(node *head, int data)
{
node *temp;
if (head == NULL)
return create_node(data);
for (temp = head; temp->next != NULL; temp =temp->next)
;
temp->next = create_node(data);
return head;
}
void print_list(node *head)
{
node *temp;
if (head == NULL)
{
printf(“(empty list)n”);
return;
}
for (temp = head; temp != NULL; temp = temp->next)
printf(“%d%c”,
PayPal Gateway not configured
PayPal Gateway not configured