I'm new in coding and I was wondering why this code crashes when I enter some value. There are some tutorials for this, but I don't get it.
Can someone explain linked lists
very simple, please?
#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int data;
struct node *next;
}tnode;
int main()
{
tnode *head=NULL;
tnode *new=(tnode*)malloc(sizeof(tnode));
int d;
scanf("%d", d);
new->data=d;
new->next=NULL;
if(head==NULL)
{
head=new;
return;
}
return 0;
}