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; }
4 Respostas
+ 1
oh yes. Thank you so much Christopher Dorado.😊😊😊
+ 1
thank you so much KrOW for your concern. Its ok now i have done.😊😊
0
Please, save your code on "Code Playground" section and post his url here
0
You never assign memory for "p3", you wrote "p2" instead of "p3".
https://code.sololearn.com/cofbCN5fP9LV/?ref=app