fork download
  1. #include <stdio.h>
  2.  
  3. typedef struct node{
  4. int val;
  5. struct node * next;
  6. }
  7.  
  8. void lst_print(node * lst){
  9. node * current = lst;
  10. while(current != NULL){
  11. prntf("%d\n", current->val);
  12. current = current->next;
  13. }
  14. }
  15.  
  16. int main(void) {
  17.  
  18. node * list = malloc(sizeof(node));
  19.  
  20. node->val = 0;
  21. node->next = malloc(sizeof(node));
  22.  
  23. node->next->val = 1;
  24. node->next->next = malloc(sizeof(node));
  25.  
  26. node->next->next->val = 2;
  27. node->next->next->next = NULL;
  28.  
  29. lst_print(list);
  30.  
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:8:1: error: expected ‘;’, identifier or ‘(’ before ‘void’
 void lst_print(node * lst){
 ^~~~
prog.c:8:16: error: unknown type name ‘node’
 void lst_print(node * lst){
                ^~~~
prog.c: In function ‘main’:
prog.c:18:2: error: unknown type name ‘node’
  node * list = malloc(sizeof(node));
  ^~~~
prog.c:18:2: note: use ‘struct’ keyword to refer to the type
prog.c:18:16: warning: implicit declaration of function ‘malloc’ [-Wimplicit-function-declaration]
  node * list = malloc(sizeof(node));
                ^~~~~~
prog.c:18:16: warning: incompatible implicit declaration of built-in function ‘malloc’
prog.c:18:16: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
prog.c:18:30: error: ‘node’ undeclared (first use in this function)
  node * list = malloc(sizeof(node));
                              ^~~~
prog.c:18:30: note: each undeclared identifier is reported only once for each function it appears in
prog.c:29:2: warning: implicit declaration of function ‘lst_print’ [-Wimplicit-function-declaration]
  lst_print(list);
  ^~~~~~~~~
stdout
Standard output is empty