fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct list_head
  5. {
  6. struct list_head *next, *prev;
  7. };
  8.  
  9. struct num
  10. {
  11. int number;
  12. struct list_head list;
  13. };
  14.  
  15. int main()
  16. {
  17. struct num *head = malloc(sizeof(struct num));
  18. struct num *tmp = head;
  19.  
  20. tmp->number = 0;
  21. tmp->list.prev = NULL;
  22. tmp->list.next = malloc(sizeof(struct num));
  23.  
  24. printf("tmp = %x\n", tmp);
  25. printf("number1 = %d, prev1 = %x, next1 = %x\n"\
  26. , tmp->number, tmp->list.prev, tmp->list.next);
  27.  
  28. tmp = tmp->list.next; //?颱?銝€??暺?
  29. tmp->number = 1;
  30. tmp->list.prev = head;
  31. tmp->list.next = NULL;
  32.  
  33. printf("tmp = %x\n", tmp);
  34. printf("number2 = %d, prev2 = %x, next2 = %x\n"\
  35. , tmp->number, tmp->list.prev, tmp->list.next);
  36.  
  37.  
  38. return 0;
  39. }
  40.  
  41.  
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
tmp = 4fd00010
number1 = 0, prev1 = 0, next1 = 4fd00030
tmp = 4fd00030
number2 = 1, prev2 = 4fd00010, next2 = 0