-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ch_5_phonebook.c
48 lines (42 loc) · 957 Bytes
/
Ch_5_phonebook.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
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#define MAX_SIZE 30
typedef struct
{
char *name[MAX_SIZE];
int number;
}phonebook_t;
phonebook_t phonebook ;
int main()
{
int i=0;
char *name[MAX_SIZE];
printf("phone book\n");
do
{
printf(" Enter name and phone --> enter 1 \nQuit--> enter 0..\n");
scanf("%i",&i);
if(i==1)
{
printf("Enter name : ");
_flushall();
gets(phonebook.name);
printf("Enter Number : ");
scanf("%i",&phonebook.number);
}
else
{
break;
}
}while(true);
printf("Enter the name you need to know its number : ");
_flushall();
gets(name);
if(strcmp(phonebook.name , name)==0)
{
printf("name : %s \t number : %i \n",phonebook.name , phonebook.number);
}
return 0;
}