fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct list {
  5. int key;
  6. struct list *next;
  7. };
  8.  
  9. struct list *append(struct list **l1, int k)
  10. {
  11. *l1 = malloc(sizeof *l1);
  12. (*l1)->key = k;
  13. return *l1;
  14. }
  15.  
  16. int main(void)
  17. {
  18. struct list *p, *l1;
  19. int i;
  20.  
  21. for (p = l1, i = 0; i < 42; ++i)
  22. p = append(&p, i);
  23.  
  24. for (struct list *p = l1; p != NULL; p = p->next)
  25. printf("%d\n", p->key);
  26. }
  27.  
Runtime error #stdin #stdout 0.01s 1852KB
stdin
Standard input is empty
stdout
Standard output is empty