-
Notifications
You must be signed in to change notification settings - Fork 0
/
info.h
50 lines (39 loc) · 794 Bytes
/
info.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
typedef struct info {
int ID;
char nome[MAXBUFF];
// . . .
} INFO;
INFO INFO_default_value()
{
INFO i;
i.ID = -999;
strcpy(i.nome, "---");
return i;
}
INFO INFO_set_value(int id, char *nome)
{
INFO i;
i.ID = id;
strcpy(i.nome, nome);
return i;
}
INFO INFO_set_interativo(char *titulo)
{
INFO i;
printf("\n%s:\n", titulo);
printf("ID >>> ");
scanf("%d", &i.ID);
clear_buffer();
printf("NOME >>> ");
fgets(i.nome, sizeof(i.nome), stdin);
size_t length = strlen(i.nome);
if (length > 0 && i.nome[length - 1] == '\n') {
i.nome[length - 1] = '\0';
}
return i;
}
bool INFO_is_equal(INFO x, INFO y)
{
if(x.ID == y.ID && strcmp(x.nome, y.nome) == 0) return true;
return false;
}