diff --git a/poly/src/exemple.c b/poly/src/exemple.c index 2397a5e..4798532 100644 --- a/poly/src/exemple.c +++ b/poly/src/exemple.c @@ -7,23 +7,26 @@ struct liste { }; typedef struct liste liste_t; +// Alloue une nouvelle cellule de +// valeur `val` liste_t* alloc_cell(int val) { - liste_t* cell = malloc(sizeof(liste_t)); + liste_t* cell = + malloc(sizeof(liste_t)); cell->valeur = val; cell->suivant = NULL; return cell; } -void afficher_liste(liste_t* tete, int taille) { - liste_t* cur = tete; +// Affiche les `taille` 1ères valeurs de `liste` +void afficher_liste(liste_t* liste, int taille) { + liste_t* cur = liste; for(int pos=0; pos < taille; ++pos) { printf("%d\n", cur->valeur); cur = cur->suivant; } } - int main(int argc, char** argv) { - int n = atoi(argv[1]); + int n = atoi(argv[1]); // premier argument liste_t* tete = alloc_cell(1); tete->suivant = alloc_cell(2); afficher_liste(tete, n);