fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct node {
  5. int value;
  6. struct node * next;
  7. };
  8.  
  9. struct node* function1(struct node *p) {
  10. p = p->next;
  11. return p;
  12. }
  13.  
  14. void function2(struct node **p) {
  15. (*p) = (*p)->next;
  16. }
  17.  
  18. int main(void) {
  19.  
  20. struct node * p1 = (struct node*)calloc(1, sizeof(struct node));
  21. struct node * p2 = (struct node*)calloc(1, sizeof(struct node));
  22. p1->next = NULL;
  23. p2->next = NULL;
  24. printf("p1 = %p; and p2 = %p\n", p1, p2);
  25. function1(p1);
  26. function2(&p2);
  27. printf("p1 = %p; and p2 = %p", p1, p2);
  28. //head = funcion1(head);
  29. //function2(&head);
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 4368KB
stdin
Standard input is empty
stdout
p1 = 0x5604536cf260; and p2 = 0x5604536cf280
p1 = 0x5604536cf260; and p2 = (nil)