fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5.  
  6. struct liste
  7. {
  8. char * data;
  9. struct liste * next;
  10. };
  11. typedef struct liste Node;
  12. Node *current,*head;
  13.  
  14. void add(char *chr)
  15. {
  16. current->data = chr;
  17. Node *tmp = (Node*)malloc(sizeof(Node));
  18. tmp->next = NULL;
  19. current->next = tmp;
  20. printf("word added: %s \t\t head: %s\n",current->data,head->data);
  21. current = current->next;
  22. }
  23.  
  24. int main() {
  25. current = (Node *)malloc(sizeof(Node));
  26. current->next = NULL;
  27. head = current;
  28.  
  29. char c[20];
  30. add("lol");
  31. add("you");
  32. add("wish");
  33.  
  34. return 0;
  35.  
  36.  
  37. }
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
word added: lol 		 head: lol
word added: you 		 head: lol
word added: wish 		 head: lol