-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathPhoneBookApplication
124 lines (111 loc) · 2.71 KB
/
PhoneBookApplication
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
117
118
119
120
121
122
123
#include <iostream>
using namespace std;
#include <stdio.h>
#include<string.h>
struct dict{
char name[50];
char num[11];
char mail[35];
}sp[25];
int h,i=1;
int main()
{
printf("----------------------------------------WELCOME TO E PHONE BOOK-------------------------\n");
int c,y,addcon,a=1;
int choice,v,pos;
char b[50];
while(a==1)
{
printf("1--->DISPLAY CONTACTS\n2--->DELETING CONTACTS\n3--->ADDING CONTACTS\n4--->FINDING CONTACTS");
printf("\nENTER YOUR CHOICE:");
scanf("%d",&choice);
for (int j=0;j<140;j++){
printf("_");}
if(choice<=4){
switch(choice)
{
case 1:
printf("\nREG NO\tNAME\t\tNUMBER\t\t\tEMAIL");
for(int n=1;n<i;n++)
{
printf("\n%d\t%s\t\t%s\t\t%s",n,sp[n].name,sp[n].num,sp[n].mail);
}
printf("\n");
for (int j=0;j<140;j++){
printf("_");}
break;
case 2:
printf("\nENTER THE REG NO OF CONTACT TO REMOVE:");
scanf("%d",&h);
if(h>=i)
{
printf("INVALID REG NO");
}
else{
for (c = h ; c <=i ; c++)
{
strcpy(sp[c].name,sp[c+1].name);strcpy(sp[c].num,sp[c+1].num);strcpy(sp[c].mail,sp[c+1].mail);
}
i--;
for(int n=1;n<i;n++)
{
printf("\n%d\t%s\t\t%s\t%s",n,sp[n].name,sp[n].num,sp[n].mail);
}}
printf("\n");
for (int j=0;j<140;j++){
printf("_");}
break;
case 3:
printf("\nADDING CONTACT");
printf("\nENTER THE NO OF PERSONS TO BE ADDED:");
scanf("%d",&addcon);
for (v=i;v<i+addcon;++v)
{
printf("\nenter name:");
scanf("%s",sp[v].name);
printf("\nenter number:");
scanf("%s",sp[v].num);
printf("\nenter mail:");
scanf("%s",sp[v].mail);
}
printf("\n");
for (int j=0;j<140;j++){
printf("_");}
i=v;
printf("\nAFTER CHANGING\n");
printf("REG NO\tNAME\t\tNUMBER\t\t\tEMAIL");
for(int n=1;n<i;n++)
{
printf("\n%d\t%s\t\t%s\t\t%s",n,sp[n].name,sp[n].num,sp[n].mail);
}
printf("\n");
for (int j=0;j<140;j++){
printf("_");}
break;
case 4:
printf("\nENTER THE REG NO OF THE PERSON:");
scanf("%d",&pos);
if(pos>=i)
{
printf("INVALID REG NO");
}
else{
for (int y=pos-1;y<pos;y++)
{
printf("NAME:%s\n",sp[pos].name);
printf("PHONE NUMBER:%s\n",sp[pos].num);
printf("MAIL ID:%s\n",sp[pos].mail);
}}
printf("\n");
for (int j=0;j<140;j++){
printf("_");}
break;
}
}
else{
printf("\nINVALID CHOICE");
}
printf("\nPRESS 1 TO CONTINUE 0 T0 EXIT");
scanf("%d",&a);
}
}