Linked list ....0000


#1

Node* Insert(Node *head,int data)
{
Node newnodehead=(Node)malloc(sizeof(Node));
newnodehead->data=data;
newnodehead->next=Null;
if(head==Null)
{
head=newnodehead;
}return head;
newnodehead->next=head;
head=newnodehead;
return head;

}
The above code is written to insert node at the head of link list.but this code is showing error that null was not declared in the scope.The above cod is written in c++.


#2

In the start, you need to declare a node having value null and then, you can attach or perform insertion on it. Otherwise, the program will not know where to start. It is like declaration at starting.