-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployeeone.c
More file actions
42 lines (38 loc) · 1.22 KB
/
employeeone.c
File metadata and controls
42 lines (38 loc) · 1.22 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
#include <string.h>
#include "employee.h"
EmployeePtr searchEmployeeByNumber(ConstEmployeePtr ptr, int tableSize, long targetNumber) {
const ConstEmployeePtr endPtr = ptr + tableSize;
for (; ptr < endPtr; ptr++) {
if (ptr -> number == targetNumber) {
return (EmployeePtr) ptr;
}
}
return NULL;
}
EmployeePtr searchEmployeeByName(ConstEmployeePtr ptr, int tableSize, char* targetName) {
const ConstEmployeePtr endPtr = ptr + tableSize;
for (; ptr < endPtr; ptr++) {
if (strcmp(ptr -> name, targetName) == 0) {
return (EmployeePtr) ptr;
}
}
return NULL;
}
EmployeePtr searchEmployeeByPhone(ConstEmployeePtr ptr, int tableSize, char* targetPhone) {
const ConstEmployeePtr endPtr = ptr + tableSize;
for (; ptr < endPtr; ptr++) {
if (strcmp(ptr -> phone, targetPhone) == 0) {
return (EmployeePtr) ptr;
}
}
return NULL;
}
EmployeePtr searchEmployeeBySalary(ConstEmployeePtr ptr, int tableSize, double targetSalary) {
const ConstEmployeePtr endPtr = ptr + tableSize;
for (; ptr < endPtr; ptr++) {
if (ptr -> salary == targetSalary) {
return (EmployeePtr) ptr;
}
}
return NULL;
}