#include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string.h> // Structure typedef struct maListe { char mot[5]; char type; maListe *suivant; }liste; void ajoute(liste* maListeDeChaine, char *laChaine, char leType) { liste * p_current = maListeDeChaine; while (p_current->suivant != NULL) p_current = p_current->suivant; p_current->suivant = (liste*) malloc (sizeof(liste));; strcpy(p_current->suivant->mot, laChaine); p_current->suivant->type = leType; p_current->suivant->suivant = NULL; } int main(int argc, char* argv[]) { liste a; strcpy(a.mot,"abc"); a.type = 'c'; a.suivant = NULL; ajoute(&a,"bcd",'d'); ajoute(&a,"cde",'e'); return 0; }
((*nouv)->mot[j]) = mot_regle[j];
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionptr_liste * maListe = NULL; insertion_un_mot("truc", maListe);
maListe = insertion_un_mot("truc", maListe);
#include <stdio.h> #include <stdlib.h> // Structure typedef struct maListe { char mot[5]; char type; maListe *suivant; }liste; void ajoute(liste * laListe) { laListe = (liste*) malloc (sizeof(liste)); printf("Pendant appel : %p\n",laListe); } main() { liste * testListe = NULL; printf("Avant appel : %p\n",testListe); ajoute(testListe); printf("Après appel : %p\n",testListe); return 0; }