I am not able to see the desired output.
Please let me know where I am missing a point.
#include<stdio.h>
struct node{
int data;
struct node *next;
};
void push_node(struct node *node, int data){
struct node *new_node = (struct node *)malloc(sizeof(struct node));
if(node!=NULL){
new_node->data = data;
new_node->next = node;
node = new_node;
}else{
new_node->data = data;
new_node->next = NULL;
node = new_node;
}
}
void display_node(struct node *node){
struct node *temp =(struct node *)malloc(sizeof(node));
temp = node;
while(temp != NULL){
printf("%d ",temp->data);
temp = temp->next;
}
}
int main(){
struct node* head = NULL;
push_node(head, 10);
push_node(head, 2);
display_node(head);
getchar();
return 0;
}