#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node{
int num;
int deg;
struct node* nxt;
struct node* prv;
};
typedef struct node node_t;
void push(node_t *head, node_t *last, int number, int degree){
node_t *newNode = (node_t*)malloc(sizeof(node_t));
newNode->num = number;
newNode->deg = degree;
newNode->nxt = NULL;
newNode->prv = NULL;
if(head == NULL){
head = newNode;
last = newNode;
}
else{
last->nxt = newNode;
newNode->prv = last;
last = newNode;
}
}
int main(){
node_t *pol1 = NULL;
node_t *pol1F=NULL;
int dataNum, dataDeg;
dataNum =1;
dataDeg =2;
push(pol1, pol1F, dataNum , dataDeg);
printf("%d", pol1->num );
free(pol1);
free(pol1F);
return 0;
}
When trying to print a number from node I get status -1073741819. In the function, as long as I know, it should associate head with pol1 and enter the first if, considering head = NULL. In the future I will add other nodes and create another "head" for a second linked list. How can I access data from pol1 ?