Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct Node
  5. {
  6. char data;
  7. struct Node* link;
  8. };
  9.  
  10. char a;
  11. int val;
  12. struct Node* top = NULL;
  13.  
  14. void push()
  15. {
  16. struct Node* NewNode = (struct Node*) malloc(sizeof(struct Node));
  17. NewNode->data = a;
  18. NewNode->link = top;
  19. top=NewNode;
  20. }
  21.  
  22. void print()
  23. {
  24. struct Node* temp = top;
  25. while(temp!=NULL)
  26. {
  27. printf("\n\n\n%c",temp->data);
  28. temp=temp->link;
  29. }
  30. printf("\n");
  31.  
  32. }
  33.  
  34. int main(){
  35. while(val=1)
  36. {
  37. scanf("%c", &a);
  38. push();
  39. print();
  40. }
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement