fork(1) download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. struct node
  4. {
  5. int data;
  6. struct node *next;
  7. };
  8. void func(struct node* );
  9. int main()
  10. {
  11. struct node *head=(struct node *)malloc(sizeof(struct node));
  12. struct node *temp=(struct node *)malloc(sizeof(struct node));
  13. struct node *first=(struct node *)malloc(sizeof(struct node));
  14. head->data=10;
  15. head->next=temp;
  16. temp->data=20;
  17. temp->next=first;
  18. first->data=30;
  19. first->next=NULL;
  20. func(head);
  21. return 0;
  22. }
  23.  
  24. void func(struct node *p)
  25. {
  26. if(p)
  27. {
  28. printf("\n%d",p->data);
  29. func(p->next);
  30. }
  31. }
Success #stdin #stdout 0s 4196KB
stdin
Standard input is empty
stdout
10
20
30