I'm trying to create a linear linked list.
Seemed pretty simple but even though the code looks fine it won't compile.
Here's the header file and the main. Could you tell me what the problem is?
#include <malloc.h>
typedef int TYP;
typedef struct
{
TYP info;
node_linear_linked_list *next;
} node_linear_linked_list;
void init_linear_linked_list(node_linear_linked_list **manager)
{
*manager = NULL;
}
void push_linear_linked_list(node_linear_linked_list **manager, TYP info)
{
node_linear_linked_list *ptr =
(node_linear_linked_list *)malloc(sizeof(node_linear_linked_list));
ptr->info = info;
ptr->next = *manager;
*manager = ptr;
}
void insert_after_linear_linked_list(node_linear_linked_list *before, TYP info)
{
node_linear_linked_list *ptr =
(node_linear_linked_list *)malloc(sizeof(node_linear_linked_list));
ptr->info = info;
ptr->next = before->next;
before->next = ptr;
}
void pop_linear_linked_list(node_linear_linked_list **manager)
{
node_linear_linked_list *temp_ptr = *manager;
*manager = temp_ptr->next;
free(temp_ptr);
}
void delete_after_linear_linked_list(node_linear_linked_list *before)
{
node_linear_linked_list *temp_ptr = before;
before->next = before->next->next;
free(temp_ptr);
}
here's the main:
#include <malloc.h>
#include "node_linear_linked_list.h"
void main(void)
{
node_linear_linked_list *manager =
(node_linear_linked_list *)malloc(sizeof(node_linear_linked_list));
init_node_linear_linked_list(&manager);
getch();
}
Would appreciate some help. Thanks.
typedef struct { TYP info; node_linear_linked_list *next;-->typedef struct node { TYP info; struct node *next;