46 lines
730 B
C
46 lines
730 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
struct maillon
|
|
{
|
|
char lettre;
|
|
struct maillon* suiv;
|
|
};
|
|
|
|
typedef struct maillon maillon;
|
|
|
|
int estVide(maillon *chaine)
|
|
{
|
|
return(chaine == NULL);
|
|
}
|
|
|
|
void afficher(maillon *chaine)
|
|
{
|
|
maillon *lecture=chaine;
|
|
while(!estVide(lecture))
|
|
{
|
|
printf("%c", lecture->lettre);
|
|
lecture=lecture->suiv;
|
|
}
|
|
printf("\n");
|
|
}
|
|
|
|
maillon* ajouterDebut(maillon *m,char c)
|
|
{
|
|
maillon *p = malloc(sizeof(maillon));
|
|
p -> lettre=c;
|
|
p -> suiv = m;
|
|
|
|
return p;
|
|
}
|
|
|
|
int main(int argc, char const *argv[])
|
|
{
|
|
maillon *chaine=malloc(sizeof(maillon));
|
|
chaine->lettre='t';
|
|
chaine = ajouterDebut(chaine,'s');
|
|
chaine = ajouterDebut(chaine,'e');
|
|
chaine = ajouterDebut(chaine,'t');
|
|
afficher(chaine);
|
|
return 0;
|
|
} |