Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. typedef struct Node{
  4. int value;
  5. struct node * next;
  6. }node;
  7.  
  8. typedef struct Stack{
  9. node * head;
  10. }stack;
  11.  
  12. void pop(stack * st){
  13. node * temp = st->head;
  14. st->head = st->head->next;
  15. free(temp);
  16. }
  17.  
  18. void push(stack * st,int value){
  19. node * temp;
  20. temp->value = value;
  21.  
  22. temp->next = st->head;
  23. st->head = temp;
  24.  
  25. }
  26.  
  27. // typedef struct asd{
  28. // int a;
  29. // }Nurbek;
  30.  
  31. int main()
  32. {
  33. stack st;
  34. node myNode;
  35. myNode.value = 1;
  36. st.head = &myNode;
  37.  
  38. push(&st,2);
  39.  
  40. printf("%d\n",st.head->value);
  41.  
  42. node * temp = st.head;
  43.  
  44. while(temp){
  45. printf("asdfosadifj\n");
  46. printf("%d\n",temp->value);
  47. temp = temp->next;
  48. }
  49.  
  50. printf("Hello, World!\n");
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement