12.07.2015 Views

Langage Ca - Pages de Michel Deloizy - Free

Langage Ca - Pages de Michel Deloizy - Free

Langage Ca - 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.

• Initialisation <strong>de</strong> donnéeso Exemple :void fonctionZ(void){const char t1[ ]="toto est le plus beau";→ t1 est un tableau constant <strong>de</strong> 22 caractères→ la chaîne <strong>de</strong> caractères est chargée au démarrage du programme→ le contenu <strong>de</strong> t1 n'est pas modifiable}127• Initialisation <strong>de</strong> donnéeso Exemple :void fonctionW(void){char *t1="toto est le plus beau";→ t1 est un pointeur initialisé sur une chaîne <strong>de</strong> caractères constante (à chaque appel <strong>de</strong>fonctionW)}128• Initialisation <strong>de</strong> donnéeso Exemple :void fonctionY(void){static char *t1="toto est le plus beau";→ t1 est un pointeur initialisé au chargement du programme sur une chaîne <strong>de</strong> caractèresconstante→ t1 pourra être modifié (pour pointer sur une autre chaîne)}129• Initialisation <strong>de</strong> donnéeso Exemple :double tab[ ]={1.0, 3.0, 5.0, 7.0};char *mots[ ]={"toto","titi","tata",0};struct {char *nom;double val;} liste[100] = {{ "pi", 3.14 },{ "x", 200.12 },};130 Fonction main• Démarrage du programme• Renvoie une valeur entière au système d'exploitation→ co<strong>de</strong> d'erreur• Admet 3 paramètres :int main(intint argc, , char *argv*argv[ [ ], char *arge*arge[ [ ])131 Exemple• Paramètres "transmis" par le système d'exploitation• argc : nombre <strong>de</strong> paramètres sur la ligne <strong>de</strong> comman<strong>de</strong> (à l'invocation du programme)• argv : chaînes <strong>de</strong> caractères contenant les paramètres• arge : variables d'environnement

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

Saved successfully!

Ooh no, something went wrong!