second node doesn't print
Why the second node in list doesn't print
Code:
#include<stdio.h>#include<stdlib.h>
struct node{
int Number;
struct node *next;
};
struct node* newNode(int number, struct node *next) {
struct node *new = malloc(sizeof(*new));
new->Number = number;
new->next = next;
return new;
}
void show(struct node *head){
struct node *c;
c = head;
while (c!=NULL){
printf("%d\n",c->Number);
c = c->next;
}
}
int main (void )
{
struct node *head = NULL;
struct node *first = NULL;
struct node *second = NULL;
first = newNode(10, head);
head = first;
second = newNode(20, head);
head = first;
show(head);
return 0;
}
10