-
Notifications
You must be signed in to change notification settings - Fork 0
/
add.h
59 lines (59 loc) · 1.75 KB
/
add.h
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
void add_file(contact s[])
{
int n,i,c=count;
printf("How many contacts do you want to add?\n");
scanf("%d",&n);
for(i=c; i<(c+n); i++)
{
printf("\nContact [#%d]\n", i+1);
printf(" Enter last name: ");
scanf("%s",s[i].lastname);
printf(" Enter first name: ");
scanf("%s",s[i].firstname);
printf(" Enter birth date:\n");
printf(" Day: ");
do
{
scanf("%d", &s[i].dob.day);
if (s[i].dob.day <0 || s[i].dob.day>31)
printf(" Please enter a valid number: ");
}
while (s[i].dob.day <0 || s[i].dob.day>31);
printf(" Month: ");
do
{
scanf("%d", &s[i].dob.month);
if (s[i].dob.month<0 || s[i].dob.month>12)
printf(" Please enter a valid number: ");
}
while (s[i].dob.month<0 || s[i].dob.month>12);
printf(" Year: ");
do
{
scanf("%d", &s[i].dob.year);
if (s[i].dob.year<0)
printf(" Please enter a valid number: ");
}
while (s[i].dob.year<0);
printf(" Enter the address: ");
fgets(s[i].adress, 50, stdin);
printf(" Enter the email: ");
do
{
scanf("%s",s[i].email);
if (validate_email(s[i].email)==1)
printf(" Please enter a valid email: ");
}
while (validate_email(s[i].email)==1);
printf(" Enter the number: ");
do
{
scanf("%s", s[i].number);
if (validate_phone(s[i].number)==1)
printf(" Please enter a valid phone number: ");
}
while(validate_phone(s[i].number)==1);
count++;
}
printf("\n");
}