Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #define size 6
  5.  
  6. void exit();
  7. void sort();
  8. void display();
  9. void startstack();
  10. void push();
  11. void create();
  12. void enterpid();
  13. int temp, productid, bid, flag, stop, choice, select;
  14.  
  15. struct stack{
  16. int topofpstack;
  17. int productid[size];
  18. int bid[6];
  19. }s;
  20.  
  21.  
  22. void create()
  23. {
  24. s.topofpstack = -1;
  25. }
  26.  
  27. void main()
  28. {
  29. create();
  30. flag = 0;
  31. system("cls");
  32. printf("\n Automated Stockroom\n");
  33. printf("\n 1. Insertion");
  34. printf("\n 2. Display");
  35. printf("\n 3. Exit");
  36. scanf_s("%d", &select);
  37. switch (select)
  38. {
  39. case 1:
  40. do
  41. {
  42. startstack();
  43. flag = 1;
  44. } while (flag != 1);
  45. case 2:
  46. display();
  47. case 3:
  48. exit();
  49. }
  50. }
  51.  
  52. void startstack()
  53. {
  54. stop = 0;
  55. printf("\n Enter the Bin ID: ");
  56. scanf_s("%d", &bid);
  57. do{
  58. enterpid();
  59.  
  60. printf("\n Do you want to enter another Product ID?");
  61. scanf_s("%s", &choice);
  62. switch (choice)
  63. {
  64. case 'Y':
  65. case 'y':
  66. enterpid();
  67. case 'N':
  68. case 'n':
  69. stop = 1;
  70. return main;
  71. }
  72. } while (stop != 1);
  73. return main();
  74. }
  75.  
  76. void enterpid()
  77. {
  78. printf("\n Enter the Product ID: ");
  79. scanf_s("%d", &productid);
  80.  
  81. push(productid);
  82. }
  83.  
  84. void push(int productid)
  85. {
  86. if (s.topofpstack == size - 1)
  87. {
  88.  
  89. }
  90. else
  91. {
  92. s.topofpstack++;
  93. s.productid[s.topofpstack] = productid;
  94. if (s.topofpstack = size)
  95. {
  96.  
  97. }
  98. sort();
  99. }
  100. }
  101.  
  102. void display()
  103. {
  104. int temp = s.topofpstack;
  105. if (temp == -1)
  106. {
  107. printf("it's emtpy");
  108. }
  109. else
  110. {
  111. while (temp != 1)
  112. {
  113. printf("\n\n %d", s.productid[temp]);
  114. temp--;
  115. }
  116. }
  117. system("pause");
  118. return main();
  119. }
  120.  
  121. void sort()
  122. {
  123.  
  124. }
  125.  
  126. void exit()
  127. {
  128. exit(0);
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement