-
Notifications
You must be signed in to change notification settings - Fork 0
/
person-functions.c
73 lines (62 loc) · 1.23 KB
/
person-functions.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
/*
* person-functions.c -- functions that can be applied on cars
*/
#include "person-functions.h"
#include <string.h>
#include <stdbool.h>
#define MAXREG 10
typedef struct person_f {
char name[MAXREG];
int age;
double height;
} person_ft;
/*
*change person plate
*/
void change_name(person_ft * pp, char *name) {
strcpy(pp->name, name);
}
/*
*change person age
*/
void change_age(person_ft *pp, int age) {
pp->age = age;
}
/*
*change car year
*/
void change_height(person_ft *pp, double height) {
pp->height = height;
}
/*
*change all attributes
*/
void change_all(person_ft *pp, char *name, int age, double height) {
change_plate(pp, name);
change_price(pp, age);
change_year(pp, height);
}
/*
*compare car plate
*/
bool compare_name(person_ft *pp, char *name) {
return strcmp(pp->name, name);
}
/*
*compare car price
*/
bool compare_age(person_ft *pp, int age) {
return pp->age == age;
}
/*
*compare person height
*/
bool compare_height(person_ft *pp, double height) {
return pp->height == height;
}
/*
*compare all attributes
*/
bool compare_all(person_ft *pp, char *name, int age, double height) {
return compare_name(pp, name) && compare_age(pp, age) && compare_height(pp, height);
}