-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
86 lines (78 loc) · 2.62 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/***************************************************************************
* @file lab6.c
* @brief Zombie Apocolypse main function
* @author Jennifer Quay Minnich
* @date Oct 20, 2020
*
* @details This program is a Zombie Apocolypse log that will keep track of the
* zombies encountered. This program uses structs, enumerations, and
* arrays, along with fgets and sscanf for user input.
*
* @bug none
*
* @todo none
**************************************************************************/
#include "zombie.h"
#include <stdio.h>
#include <stdlib.h>
#define ENTER_ZOMBIE 1
#define DISPLAY_INFO 2
#define QUIT 3
#define LEN 32
int main(void)
{
struct zombie data[SIZE];
char buf[LEN];
char dead;
int i = -1;
int menu;
while (1)
{
printf("\n1. Enter new zombie information\n");
printf("2. Display zombie information\n");
printf("3. Return to fighting zombies (exit)\n");
printf("Enter selection: ");
fgets(buf, LEN, stdin);
menu = atoi(buf);
switch(menu)
{
case ENTER_ZOMBIE:
//index will store up to 5 zombies in database
i = (i +1) % 5;
printf("\nWas the zombie found dead? Y or N : ");
fgets(buf, LEN, stdin);
sscanf(buf, "%c", &dead);
switch (dead)
{
case 'Y':
case 'y':
//call function input_toes
input_toes(buf, data, i);
//call function input_time
input_time(buf, data, i);
break;
case 'N':
case 'n':
//call input_blood
input_blood(buf, data, i);
//call function input_time
input_time(buf, data, i);
break;
}
break;
case DISPLAY_INFO:
print_zombies(buf, data, i, dead);
break;
case QUIT:
printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("Stay alert! Keep a watch out for zombies!!\nGOODBYE and GOOD LUCK!\n");
exit(EXIT_SUCCESS);
break;
default:
printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
printf("A zombie has attacked! (You entered something I don't understand). \n\n");
break;
}
};
return 0;
}