I tried inserting node at the end of doubly-linked list with a insert function but the process execution stops abruptly after second insertion. I tried checking out address of all pointer variable used in insert function and they show that my code works fine until the third insert function. How can I fix my code?
#include <stdio.h>
#include <stdlib.h>
struct node {
    int data;
    struct node* next;
    struct node* prev;
};
void insert(struct node** header,int data) {
    struct node* newnode=(struct node*)malloc(sizeof(struct node*));
    newnode->data=data;
    newnode->prev=NULL;
    newnode->next=NULL;
    if(*header == NULL) {
        *header=newnode;
        return;
    }
    struct node* temp = *header;
    while(temp->next != NULL) {
        temp=temp->next;
    }
    temp->next = newnode;
    newnode->prev = temp;
    printf("%d\n**\n", temp->next);
}
void main() {
    struct node* head = NULL;
    insert(&head, 4);
    insert(&head, 45);
    printf("\n main head %d", head);
    insert(&head, 8);
    printf("testing");
    insert(&head, 69);
}
 
     
    