#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
void printList(struct node *node)
{
while(node != NULL) {
printf("%d ", node->data);
node = node->next;
}
printf("\n");
}
void freeList(struct node *node)
{
struct node *tmp = NULL;
while(node != NULL) {
tmp = node;
node = node->next;
free(tmp);
tmp = NULL;
}
}
void push(struct node **head_ref, int new_data)
{
struct node *new_node = (struct node *)malloc(sizeof(struct node));
new_node->data = new_data;
new_node->next = *head_ref;
(*head_ref) = new_node;
}
int main(int argc, char *argv[])
{
struct node *res = NULL;
push(&res, 15);
push(&res, 34);
push(&res, 16);
push(&res, 11);
push(&res, 10);
printList(res);
freeList(res);
return 0;
}#includ