09.01.2015 Views

Langage C - Pages de Michel Deloizy - Free

Langage C - Pages de Michel Deloizy - Free

Langage C - Pages de Michel Deloizy - Free

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

LICENCE SPI-EEA LANGAGE C M. <strong>Deloizy</strong><br />

La fonction InitTab aurait pu également être écrite ainsi :<br />

void InitTab(int *baseTab, unsigned nb)<br />

{<br />

while(nb--) *(baseTab++)=0;<br />

}<br />

Les paramètres étant transmis à la fonction par valeur, et ces <strong>de</strong>rniers étant locaux à la fonction, leur modification dans<br />

la fonction ne change pas la valeur <strong>de</strong>s données transmises en arguments lors <strong>de</strong> l'appel.<br />

Par contre, on accè<strong>de</strong> aux éléments <strong>de</strong> tableau par l'intermédiaire <strong>de</strong> l'adresse du tableau.<br />

Autre exemple permettant la recherche <strong>de</strong> minima et maxima :<br />

void MinMax(double x, double *Min, double *Max)<br />

{<br />

if(x < *Min) *Min = x;<br />

else if(x > *Max) *Max = x;<br />

}<br />

...<br />

double tab[100];<br />

unsigned i;<br />

double mini, maxi;<br />

...<br />

mini = maxi = *tab;<br />

for(i=1; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!