Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>

struct node
{
    int data;
    int data2;
    struct node *link;
};

void addatbeg(struct node **q,int num,int num2)
{
    struct node *temp;

    temp=(struct node *)malloc(sizeof(struct node));
    temp->data=num;
    temp->data2=num2;
    temp->link=*q;
    *q=temp;
    
}

void display (struct node *q)
{
    while(q!=0)
    {
        printf("%d\t %d\t",q->data,q->data2);
        q=q->link;
    }
    printf("\n");
}

void main()
{
  struct node *p;
  p=NULL;

  addatbeg(&p,123,43);
  display(p)  ;
  addatbeg(&p,97,47);
  display(p);

}

I want to ask what memory should I free ? The linked list or just the pointer p ?
And after the execution of the program is done,ie I exit the IDE is the dynamically allocated memory still in use ? Same for the Pointer.

I have not been able to figure out what to free, but I assume we use the free() function for it.

Thanks