+ 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); }
4 Réponses
+ 13
welcome brother
+ 12
https://code.sololearn.com/cP57CnoM41mi/?ref=app
I have modified your code
+ 1
thanks
0
but why it is not being identified in python version 2.7