fork download
  1. #include<stdio.h>
  2. #include<malloc.h>
  3. struct node
  4. {
  5. int data;
  6. struct node *link;
  7. };
  8. void create(struct node **,int);
  9. void display(struct node *);
  10. struct node* reverselist(struct node **);
  11. int main()
  12. {
  13. struct node *p,*q;
  14. p=NULL;
  15. create(&p,1);
  16. create(&p,2);
  17. create(&p,3);
  18. create(&p,4);
  19. create(&p,5);
  20. printf("before:\n");
  21. display(p);
  22. q=reverselist(&p);
  23. printf("\n after");
  24. display(q);
  25. return 0;
  26. }
  27. void create(struct node **q,int num)
  28. {
  29. struct node *temp,*r;
  30. if(*q==NULL)
  31. {
  32. temp=malloc(sizeof(struct node));
  33. temp->data=num; temp->link=NULL;
  34. *q=temp;
  35. }
  36. else
  37. {
  38. temp=*q;
  39. while(temp->link!=NULL)
  40. temp=temp->link;
  41. r=malloc(sizeof(struct node));
  42. r->data=num;r->link=NULL;
  43. temp->link=r;
  44. }
  45. }
  46. void display(struct node *p)
  47. {
  48. while(p!=NULL)
  49. {printf(" %d,",p->data); p=p->link;}
  50. }
  51. struct node* reverselist(struct node **q)
  52. {
  53. struct node *p;
  54. p=(*q)->link;
  55. if(q==NULL)
  56. return NULL;
  57. if(p==NULL)
  58. return (*q);
  59. (*q)->link=NULL;
  60. struct node *list=recursivelist(&p);
  61. p->link=*q;
  62. return list;
  63. }
  64.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘reverselist’:
prog.c:60:12: warning: implicit declaration of function ‘recursivelist’ [-Wimplicit-function-declaration]
prog.c:60:23: warning: initialization makes pointer from integer without a cast [enabled by default]
/home/26sZKq/cciROnss.o: In function `reverselist':
prog.c:(.text+0xb4): undefined reference to `recursivelist'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty