-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployeeMain.c
More file actions
111 lines (75 loc) · 2.7 KB
/
employeeMain.c
File metadata and controls
111 lines (75 loc) · 2.7 KB
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
#include <string.h>
#include <stdlib.h>
#include "employee.h"
int main(void){
//defined in employeeSearchOne.c
PtrToEmployee searchEmployeeByNumber(const Employee table[], int sizeTable, long numberToFind);
PtrToEmployee searchEmployeeByName(const Employee table[], int sizeTable, char * nameToFind);
PtrToEmployee searchEmployeeByPhoneNumber(PtrToConstEmployee ptr, int sizeTable, char * phoneNumberToFind);
PtrToEmployee searchEmployeeBySalary(PtrToConstEmployee ptr, int sizeTable, double salaryToFind);
//defined in employeeTable.c
extern Employee EmployeeTable[];
extern const int EmployeeTableEntries;
PtrToEmployee matchPtr;//Declaration
matchPtr = searchEmployeeByNumber(EmployeeTable, EmployeeTableEntries, 1045);
//Example not found
if (matchPtr != NULL)
{
printf("Employee ID 1045 is in record %d\n", matchPtr - EmployeeTable);
}
else
{
printf("Employee ID is NOT found in the record\n");
}
//Example found
matchPtr = searchEmployeeByName(EmployeeTable, EmployeeTableEntries, "Tony Bobcat");
if (matchPtr != NULL)
{
printf("Employee Tony Bobcat is in record %d\n", matchPtr - EmployeeTable);
}
else
{
printf("Employee Tony Bobcat is NOT found in the record\n");
}
//Example Not found
matchPtr = searchEmployeeByPhoneNumber(EmployeeTable,EmployeeTableEntries, "909-333-4444");
if(matchPtr != NULL)
{
printf("Employee with number 909-559-2134 is in the record %d\n", matchPtr-EmployeeTable);
}
else
{
printf("Employee with number 909-559-2134 is NOT found in the record\n");
}
//example found
matchPtr = searchEmployeeByPhoneNumber(EmployeeTable,EmployeeTableEntries, "213-555-1212");
if(matchPtr != NULL)
{
printf("Employee with number 213-555-1212 is in the record %d\n", matchPtr-EmployeeTable);
}
else
{
printf("Employee with number 213-555-1212 is NOT found in the record\n");
}
//example NOT found
matchPtr = searchEmployeeBySalary(EmployeeTable, EmployeeTableEntries, 6.20);
if (matchPtr != NULL)
{
printf("Employee salary 6.20 is in record %d\n", matchPtr - EmployeeTable);
}
else
{
printf("Employee salary is NOT found in the record\n");
}
//example was found
matchPtr = searchEmployeeBySalary(EmployeeTable, EmployeeTableEntries, 5.20);
if (matchPtr != NULL)
{
printf("Employee salary 5.20 is in record %d\n", matchPtr - EmployeeTable);
}
else
{
printf("Employee salary is NOT found in the record\n");
}
return EXIT_SUCCESS;
}