fork download
  1. struct list {
  2. int key;
  3. struct list *next;
  4. };
  5.  
  6. void append(struct list *l1, struct l2)
  7. {
  8. l1 = malloc(sizeof *l1);
  9. *l1 = l2;
  10. l1->next = NULL;
  11. }
  12.  
  13. int main(void)
  14. {
  15. struct list *l1, l2 = { 42, NULL }, l3 = { 24, NULL };
  16.  
  17. append(l1, l2);
  18. append(l1->next, l3);
  19.  
  20. for (struct list *p = l1; p != NULL; p = p->next)
  21. printf("%d\n", p->key);
  22. }
  23.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
cc1: warnings being treated as errors
prog.c:6: error: ‘struct l2’ declared inside parameter list
prog.c:6: error: its scope is only this definition or declaration, which is probably not what you want
prog.c:6: error: parameter 2 has incomplete type
prog.c: In function ‘append’:
prog.c:6: error: parameter name omitted
prog.c:8: error: implicit declaration of function ‘malloc’
prog.c:8: error: incompatible implicit declaration of built-in function ‘malloc’
prog.c:9: error: ‘l2’ undeclared (first use in this function)
prog.c:9: error: (Each undeclared identifier is reported only once
prog.c:9: error: for each function it appears in.)
prog.c:10: error: ‘NULL’ undeclared (first use in this function)
prog.c: In function ‘main’:
prog.c:15: error: ‘NULL’ undeclared (first use in this function)
prog.c:17: error: type of formal parameter 2 is incomplete
prog.c:18: error: type of formal parameter 2 is incomplete
prog.c:21: error: implicit declaration of function ‘printf’
prog.c:21: error: incompatible implicit declaration of built-in function ‘printf’
stdout
Standard output is empty