forked from dudyas6/RestuarantC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
50 lines (46 loc) · 1.09 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#define _CRT_SECURE_NO_WARNINGS
#include "header.h"
void main()
{
FILE* open;
List plist;
int instruction, quantity, tablenum;
char productname[50];
PManot Table[50] = { NULL };
char check_arr[50] = { 0 };
plist.head = plist.tail = NULL;
open = fopen("Instructions.txt", "rt");
if (open == NULL)
endMsg("error open instructions file", &plist);
while (!feof(open)) {
rewind(stdin); // clear pointer
fscanf(open, "%d", &instruction); //
switch (instruction) // switch between cases as function of given int
{
case 1:
CreateProducts(&plist);
break;
case 2:
fscanf(open, "%s %d", &productname, &quantity);
AddItems(productname, quantity, &plist);
break;
case 3:
fscanf(open, "%d %s %d", &tablenum, &productname, &quantity);
OrderItem(Table, &plist, tablenum, productname, quantity);
break;
case 4:
fscanf(open, "%d", &tablenum);
RemoveItem(&Table, tablenum, check_arr);
break;
case 5:
fscanf(open, "%d", &tablenum);
RemoveTable(&Table, tablenum);
break;
default:
break;
}
}
fclose(open);
endMsg("", &plist);
freeTables(&Table);
}