Why this programme is not working (running)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why this programme is not working (running)?

#include<stdio.h> struct node{ int data; struct node *next; }; int main() { struct node *p1=NULL,*p2=NULL,*p3=NULL,*p4=NULL,*p5=NULL,*head=NULL,*temp=NULL; p1=(struct node *)malloc(sizeof(struct node)); p2=(struct node *)malloc(sizeof(struct node)); p2=(struct node *)malloc(sizeof(struct node)); p4=(struct node *)malloc(sizeof(struct node)); p5=(struct node *)malloc(sizeof(struct node)); head=p1; p1->next=p2;p2->next=p3;p3->next=p4;p4->next=p5;p5->next=NULL; temp=head; while(temp) { scanf("%d",&(temp->data)); temp=temp->next; } temp=head; while(temp) { printf("%d",temp->data); temp=temp->next; } return 0; }

3rd Jul 2018, 5:54 PM
Sachin Bhandari
4 Answers
+ 1
oh yes. Thank you so much Christopher Dorado.๐Ÿ˜Š๐Ÿ˜Š๐Ÿ˜Š
4th Jul 2018, 2:28 AM
Sachin Bhandari
+ 1
thank you so much KrOW for your concern. Its ok now i have done.๐Ÿ˜Š๐Ÿ˜Š
4th Jul 2018, 2:29 AM
Sachin Bhandari
0
Please, save your code on "Code Playground" section and post his url here
3rd Jul 2018, 6:17 PM
KrOW
KrOW - avatar
0
You never assign memory for "p3", you wrote "p2" instead of "p3". https://code.sololearn.com/cofbCN5fP9LV/?ref=app
3rd Jul 2018, 8:16 PM
Christopher Dorado
Christopher Dorado - avatar