I'm trying to insert a new node at the beginning of a linked list but it seems to output an error even though I think the code is correct. Can someone please show me how to fix this error? This is my insert method which outputs error on her first line. So the error is in the malloc function line. This is the error.
struct node
{
int data ;//or char or double sist e duash
struct node* next;
};
struct node* head;//krijoj nyjen head
//metoda insert
void Insert(int x){
struct node* temp=(node*)malloc(sizeof(struct node));
temp->data=x;
temp->next=head ;
head=temp;
}