Algorithmique et Langage - Pages de Michel Deloizy - Free
Algorithmique et Langage - Pages de Michel Deloizy - Free
Algorithmique et Langage - Pages de Michel Deloizy - Free
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Structures<br />
→ Agglomérats <strong>de</strong> données<br />
! Exemple :<br />
! Un individu :<br />
! Nom – Age – Profession – Poids<br />
& Ensemble <strong>de</strong> données propres à chaque individu<br />
& Informations rangées dans une variable unique (pour<br />
chaque individu)<br />
→ Champs <strong>de</strong> la structure<br />
Déclaration <strong>de</strong>s structures<br />
Déclaration :<br />
struct [TypeStructure]<br />
{<br />
TypeVar1 var1;<br />
TypeVar2 var2;<br />
…<br />
} [NomStruct1][,NomStruct2][,…] ;<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
97<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
98<br />
Utilisation <strong>de</strong>s structures<br />
Exemple <strong>de</strong> déclaration :<br />
struct TIndividu<br />
{<br />
char Nom[40];<br />
unsigned age;<br />
char Profession[80];<br />
float Poids;<br />
};<br />
struct TIndividu Marcel, Maurice;<br />
Utilisation :<br />
Chaque champ <strong>de</strong> la structure est utilisable comme une<br />
variable ordinaire (<strong>de</strong> type défini lors <strong>de</strong> la<br />
déclaration <strong>de</strong> la structure).<br />
On utilise la notation :<br />
.<br />
Exemples :<br />
scanf("%s",<br />
("%s",Marcel.Nom);<br />
Maurice.Age=32;<br />
Marcel.Poids=58.6;<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
99<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
100<br />
25