#include <stdio.h>
#include <stdlib.h>
struct node {
  int data;
  struct node *next;
};
void insertEnd(struct node *l,int val) {
  struct node *temp=(struct node*)malloc(sizeof(struct node));
  temp->data=val;
  temp->next=NULL;
  if (l==NULL) l=temp;
  struct node* p=l;
  while (p->next!=NULL) p=p->next;
  p->next=temp;
}
void display(struct node *l) {
  struct node *p=l;
  if (p==NULL) printf("Empty list");
  while (p!=NULL) {
    printf("%d ",p->data);
    p=p->next;
  }
}
int main() {
  struct node *l=NULL;
  insertEnd(l,4);
  insertEnd(l,5);
  insertEnd(l,6);
  insertEnd(l,7);
  display(l);
}
This is a very basic code for creating a linked list by inserting elements from the end and displaying it. But this keeps displaying empty list and i can't understand why. please help me out
 
    