-
Notifications
You must be signed in to change notification settings - Fork 0
/
records3.c
49 lines (46 loc) · 1.55 KB
/
records3.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
//**********************************************************************
// Written by Steven Smail for COP3514
//
// records.c (Project 11)
//
// This program maintains records for canine patients at an animal
// hospital - containing each dog’s name, breed, patient number, and
// owner’s last name.
//**********************************************************************
#include <stdio.h>
#include "dogs3.h"
/**********************************************************
* main: Prompts the user to enter an operation code, *
* then calls a function to perform the requested *
* action. Repeats until the user enters the *
* command 'q'. Prints an error message if the user *
* enters an illegal code. *
**********************************************************/
int main(void)
{
char code;
struct dog *dog_list = NULL;
printf("Operation Code: \n\ta - append the list\n\ts - search for a dog\n\tp - print the list\n\td - delete a patient\n\tq - quit\n");
for(;;)
{
printf("Enter operation code:\n");
scanf(" %c", &code);
while(getchar() != '\n') /* skips to end of line */
;
switch(code)
{
case 'a': dog_list = append(dog_list);
break;
case 's': search(dog_list);
break;
case 'p': print(dog_list);
break;
case 'd': dog_list = delete_from_list(dog_list);
break;
case 'q': clear(dog_list);
return 0;
default: printf("Illegal code.\n");
}
printf("\n");
}
}