-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
93 lines (79 loc) · 1.73 KB
/
main.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
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
#include <stdio.h>
#include <stdlib.h>
#include "structure.h"
#include "newCustomer.h"
#include "searchCustomer.h"
#include "custom_ref.h"
int displayMenu (void)
{
int choice;
char c;
printf("Please choose the following choices\n");
printf("1 - New customer\n");
printf("2 - Search customer\n");
printf("3 - Print all customers\n");
printf("4 - Print all archieved customers\n");
printf("5 - Exit\n");
scanf("%d",&choice);
printf("DEBUGGING ----------- choice = %d\n",choice);
while((c = getchar ()) != '\n' && c != EOF);
printf("DEBUGGING ------------ choice = %d\n",choice);
return choice;
}
int main (void)
{
int choice;
struct details * firstStruct = NULL;
choice = displayMenu ();
while(choice != 5)
{
if(choice == 1)
{
firstStruct = newCustomer();
//main();
printf("Inside ch 1\n");
choice = displayMenu ();
}
else if(choice == 2)
{
int N = 20;
int errorFlag = 0;//no errors
char mobileNum [N];
char c;
printf("Inside ch 2\n");
do
{
printf("Please enter customer's mobile number:\n");
fgets(mobileNum,N,stdin);//store string
while( (c = fgetc(stdin)) != '\n' && c != EOF);//clear input buffer
errorFlag = checkMobileNum(mobileNum);//check error flag
}while(errorFlag);
searchCustomer(mobileNum,firstStruct);
choice = displayMenu ();
//main ();
}
//searchCustomer ();
else if(choice == 3)
{
printf("Inside ch 3\n");
choice = displayMenu ();
//main();
}
//printCustomers ();
else if(choice == 4)
{
printf("Inside ch 4\n");
choice = displayMenu ();
//main();
}
//printArchCustomers ();
else
{
printf("inside ch > 5\n");
choice = displayMenu ();
//main ();
}
}
freePtrs(firstStruct);
return 0;
}