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.
o Classe static :<br />
o Donnée e initialisée e au chargement du programme<br />
(expression constante évaluée e par le compilateur)<br />
o La valeur peut changer au cours du programme<br />
o Pas <strong>de</strong> co<strong>de</strong> générég<br />
lors <strong>de</strong> la déclarationd<br />
Exemple :<br />
static int x=4;<br />
o Constantes :<br />
o I<strong>de</strong>m static, , avec valeur non modifiable<br />
o Exemple :<br />
void fonctionX(void)<br />
{<br />
char t1[ ]="toto est le plus beau";<br />
→ t1 est un tableau dynamique <strong>de</strong> 22 caractères<br />
→ la chaîne <strong>de</strong> caractères est recopiée à chaque appel<br />
<strong>de</strong> la fonction fonctionX<br />
→ le contenu <strong>de</strong> t1 est modifiable<br />
}<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
125<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
126<br />
! Initialisation <strong>de</strong> données<br />
o Exemple :<br />
void fonctionY(void)<br />
{<br />
static char t1[ ]="toto est le plus beau";<br />
→ t1 est un tableau statique <strong>de</strong> 22 caractères<br />
→ la chaîne <strong>de</strong> caractères est chargée au démarrage<br />
du programme<br />
→ le contenu <strong>de</strong> t1 est modifiable<br />
}<br />
! Initialisation <strong>de</strong> données<br />
o Exemple :<br />
void fonctionZ(void)<br />
{<br />
const char t1[ ]="toto est le plus beau";<br />
→ t1 est un tableau constant <strong>de</strong> 22 caractères<br />
→ la chaîne <strong>de</strong> caractères est chargée au démarrage<br />
du programme<br />
→ le contenu <strong>de</strong> t1 n'est pas modifiable<br />
}<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
127<br />
M. <strong>Deloizy</strong> <strong>Langage</strong> C<br />
128<br />
32