-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitignore
116 lines (101 loc) · 2.4 KB
/
.gitignore
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# include <string.h>
# define MAX 100 /* constant*/
struct addr { /*struct called list*/
char name[30] ;
char street[40] ;
char town[20] ;
char county[20] ;
char code[10] ;
}
list[MAX]; /* 100 records*/
void menu_select(void);
void enter(void);
void find_free(void);
void inputs( char, char, int);
int main(void)
{
clrscr();
menu_select();
getch();
return 0;
}
void menu_select()
{
int choice;
printf("1. Enter a name\n") ;
printf("2. Delete a name\n") ;
printf("3. List the File \n");
printf("4. Search\n") ;
printf("5. Save the file\n") ;
printf("6. Load the file\n") ;
printf("7. Quit\n") ;
do {
printf("\nEnter your choice: ");
}
while(choice<0 || choice>7);
scanf("%d",&choice);
switch(choice)
{
case 1: enter(); /* enter a new entry */
break;
// case 2: del(); /* delete an entry */
// break;
// case 3: show_list(); /* display the list */
// break;
// case 4: search(); /* find an entry */
// break;
// case 5: save(); /* save to disk */
// break;
// case 6: load(); /* read from disk */
// break;
case 7: exit(0);
default:
printf("Invalid choice. Please enter again");
}
getch();
}
void enter()
{
int i;
for(;;)
{
i = find_free();
if(i<0)
{
printf("list full\n");
return;
}
inputs("enter name: ", list[i].name,30);
if
(!*list[i].name) break;
inputs("enter street: ", list[i].street, 40);
inputs("enter town: ", list[i].town, 20);
inputs("enter county: ", list[i].county, 20);
inputs("enter Postal code: ", list[i].code, 10);
}
}
void find_free()
{
register int i;
for(i=0; i<MAX; i++)
if(!*list[i].name)
return i;
return -1;
}
void inputs( char *prompt , char *s , int count)
{
char str[255];
do
{
printf(prompt);
gets(str);
if
(strlen(str)>=count)
printf("\ntoo long\n");
}
while(strlen(str)>=count);
strcpy(s , str);
}