Guest User

Untitled

a guest
Dec 10th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. typedef struct DataNode
  2.  
  3. {
  4.  
  5. int id;
  6.  
  7. } DataNode;
  8.  
  9.  
  10. typedef struct Node
  11.  
  12. {
  13.  
  14. DataNode data;
  15. struct Node *Next;
  16.  
  17. } Node;
  18.  
  19. typedef struct List
  20.  
  21. {
  22.  
  23. int size;
  24. Node *head;
  25.  
  26. } List;
  27.  
  28. List *CreateList ()
  29.  
  30. {
  31.  
  32. List *list = (List*) malloc(sizeof(List));
  33.  
  34. list->size = 0;
  35. list->head = NULL;
  36.  
  37. return list;
  38.  
  39. }
  40.  
  41. void Push (List *list, DataNode data01)
  42.  
  43. {
  44.  
  45.  
  46. Node *node = (Node*) malloc (sizeof(Node));
  47.  
  48. node->data = data01;
  49. node->Next = list->head;
  50. list->head = node;
  51. list->size++;
  52.  
  53. }
Add Comment
Please, Sign In to add comment