fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct node {
  5. int data;
  6. struct node *previous, *next;
  7. } m_p;
  8.  
  9. m_p *H = NULL;
  10.  
  11. void func(void){
  12. int i, nLists = 10;
  13. H = malloc(sizeof(m_p));
  14. H->next = NULL;
  15. H->previous = NULL;
  16. H->data = -99;
  17. m_p *p = H;
  18. for(i = 0; i < nLists; i++){
  19. m_p *n = malloc(sizeof(m_p));
  20. n->next = NULL;
  21. n->previous = p;
  22. n->data = i;
  23. p->next = n;
  24.  
  25. p = p->next;
  26. }
  27.  
  28. m_p *x = H;
  29. while(x != NULL){
  30. printf("%d ", x->data);
  31. x = x->next;
  32. }
  33. }
  34.  
  35. int main(void){
  36. func();
  37. //Need free list
  38. }
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
-99 0 1 2 3 4 5 6 7 8 9