fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4.  
  5. #define StackLimit 6
  6. typedef char StackElementType;
  7.  
  8. typedef struct {
  9. int Top;
  10. StackElementType Element[StackLimit];
  11. } StackType;
  12.  
  13. typedef enum {
  14. FALSE, TRUE
  15. } boolean;
  16.  
  17. void CreateStack(StackType *Stack);
  18. boolean EmptyStack(StackType Stack);
  19. boolean FullStack(StackType Stack);
  20. void Push(StackType *Stack, StackElementType Item);
  21. void Pop(StackType *Stack, StackElementType *Item);
  22.  
  23.  
  24. main(){
  25.  
  26. StackType stack1,stack2,stack3;
  27. char tab[6];
  28.  
  29. strcpy(tab,"PASCAL");
  30.  
  31. printf("%s",tab);
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. }
  39.  
  40. void CreateStack(StackType *Stack)
  41. {
  42. Stack -> Top = -1;
  43.  
  44. }
  45.  
  46. boolean EmptyStack(StackType Stack)
  47. {
  48. return (Stack.Top == -1);
  49. }
  50.  
  51. boolean FullStack(StackType Stack)
  52. {
  53. return (Stack.Top == (StackLimit - 1));
  54. }
  55.  
  56. void Push(StackType *Stack, StackElementType Item)
  57. {
  58. if (!FullStack(*Stack)) {
  59. Stack -> Top++;
  60. Stack -> Element[Stack -> Top] = Item;
  61. } else
  62. printf("Full Stack...");
  63. }
  64.  
  65. void Pop(StackType *Stack, StackElementType *Item)
  66. {
  67. if (!EmptyStack(*Stack)) {
  68. *Item = Stack -> Element[Stack -> Top];
  69. Stack -> Top--;
  70. } else
  71. printf("Empty Stack...");
  72. }
  73.  
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
PASCAL