-
Notifications
You must be signed in to change notification settings - Fork 1
/
structures.h
66 lines (54 loc) · 1.37 KB
/
structures.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef STRUCTURES_H
#define STRUCTURES_H
#include <string.h>
#include <assert.h>
typedef struct DonneeElementaire
{
char *donnee; int taille;
void initialiser()
{
taille = 0;
donnee = new char[1];
}
void initialiser(char *chaine)
{
taille = strlen(chaine);
donnee = new char[taille+1];
assert(donnee != 0);
strncpy(donnee, chaine, taille);
}
void detruire()
{
taille = 0;
delete donnee;
}
char* operator = (const DonneeElementaire &de) // DonneeEleentaire a <-- DonneeElementaire de
{
donnee = new char[de.taille];
taille = de.taille;
strncpy(donnee, de.donnee, taille);
return donnee;
}
char* operator = (char *d) // affectation d'une valeur d'une chaine d à DonneeElementaire.
{
taille = strlen(d);
donnee = new char[taille];
strncpy(donnee, d, taille);
return donnee;
}
bool operator == (DonneeElementaire &de) // DonneeElementaire a = DonneeElementaire de
{
if (de.taille != taille)
return false;
else
{
if (strncmp(de.donnee, donnee, taille) != 0) return false;
else return true;
}
}
} DonneeElementaire;
typedef struct LigneDonnee
{
DonneeElementaire clef, valeur;
} LigneDonnee;
#endif // STRUCTURES_H