+ 1

Why append function is not working?

#include <stdio.h> #include <stdlib.h> //Compiler version gcc 6.3.0 struct Node { int data; struct Node* link; }; struct Node* head=NULL; struct Node* tail=NULL; void append(int x) { struct Node* temp=(struct Node*)malloc(sizeof(struct Node)); temp->data=x; temp->link=NULL; if(tail!=NULL) tail->link=temp; tail=temp; } int main(void) { head=tail; int n; scanf("%d",&n); int x; for(int i=0;i<n;i++) { scanf("%d",&x); append(x); } struct Node* temp=head; while((*temp).link!=NULL) { printf("%d\n",(*temp).data); temp=(*temp).link; } printf("%d",(*temp).data); }

30th May 2018, 5:52 AM
Akshay Karande
4 ответов
+ 13
welcome brother
30th May 2018, 8:26 AM
Rstar
Rstar - avatar
30th May 2018, 8:10 AM
Rstar
Rstar - avatar
+ 1
thanks
30th May 2018, 8:26 AM
Akshay Karande
0
but why it is not being identified in python version 2.7
3rd Jun 2018, 3:45 PM
Vidushi Dubey
Vidushi Dubey - avatar