Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. void add(queue *q, int x)
  2. {
  3. node_pointer temp;
  4. temp = (queue)malloc(sizeof(struct queuenode));
  5. temp -> data = x;
  6. (*q) = temp -> next;
  7. (*q) = temp;
  8.  
  9. if ((*q)==NULL)
  10. {
  11. (*q) -> front = temp;
  12. (*q) -> back = temp;
  13. }
  14. else
  15. {
  16. (*q) -> back -> next = temp;
  17. (*q) -> back = temp;
  18. }
  19. }
  20.  
  21. typedef struct queuenode {
  22. int data;
  23. struct queuenode *next;
  24. } *node_pointer;
  25.  
  26.  
  27.  
  28. typedef struct endpointer {
  29. node_pointer front;
  30. node_pointer back;
  31. } *queue;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement