it is my first attempt to create a linkedList. the code is not proper for sure but all i want to do is just to be a able to create a list and initialize it with one node for the start. the below code is syntactically correct but it is not working. can point the mistake.
#include <stdio.h>
#define SIZE 5
struct node
{ int item;
struct node *link;
};
struct linkedlist
{
struct node *head;
int count;
};
void init(struct linkedlist *p , int key)
{
struct node *newnode;
newnode = (struct node*)malloc(sizeof(struct node));
newnode->link = NULL;
newnode->item = key;
p->head = newnode;
p->count = 1;
}
void main()
{ struct linkedlist *s;
init(s , 2);
printf("%d", s->count);
}