Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define size 6
- void exit();
- void sort();
- void display();
- void startstack();
- void push();
- void create();
- void enterpid();
- int temp, productid, bid, flag, stop, choice, select;
- struct stack{
- int topofpstack;
- int productid[size];
- int bid[6];
- }s;
- void create()
- {
- s.topofpstack = -1;
- }
- void main()
- {
- create();
- flag = 0;
- system("cls");
- printf("\n Automated Stockroom\n");
- printf("\n 1. Insertion");
- printf("\n 2. Display");
- printf("\n 3. Exit");
- scanf_s("%d", &select);
- switch (select)
- {
- case 1:
- do
- {
- startstack();
- flag = 1;
- } while (flag != 1);
- case 2:
- display();
- case 3:
- exit();
- }
- }
- void startstack()
- {
- stop = 0;
- printf("\n Enter the Bin ID: ");
- scanf_s("%d", &bid);
- do{
- enterpid();
- printf("\n Do you want to enter another Product ID?");
- scanf_s("%s", &choice);
- switch (choice)
- {
- case 'Y':
- case 'y':
- enterpid();
- case 'N':
- case 'n':
- stop = 1;
- return main;
- }
- } while (stop != 1);
- return main();
- }
- void enterpid()
- {
- printf("\n Enter the Product ID: ");
- scanf_s("%d", &productid);
- push(productid);
- }
- void push(int productid)
- {
- if (s.topofpstack == size - 1)
- {
- }
- else
- {
- s.topofpstack++;
- s.productid[s.topofpstack] = productid;
- if (s.topofpstack = size)
- {
- }
- sort();
- }
- }
- void display()
- {
- int temp = s.topofpstack;
- if (temp == -1)
- {
- printf("it's emtpy");
- }
- else
- {
- while (temp != 1)
- {
- printf("\n\n %d", s.productid[temp]);
- temp--;
- }
- }
- system("pause");
- return main();
- }
- void sort()
- {
- }
- void exit()
- {
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement