push operation on stack using linked list fails
问题 I am trying to create a stack using single linked list, my push operation doesn't insert data into the linked list This is what I have tried so far, typedef struct element { int data; struct element *next; }node; The push method void push(node *root, int data) { if(root == NULL) { root = (node *) malloc (sizeof(struct element)); root->data = data; root->next = NULL; } else { node *temp = (node *) malloc (sizeof(struct element)); temp->data = data; temp->next = root; root = temp; } } In my