timy94
Messages postés50Date d'inscriptionjeudi 17 novembre 2005StatutMembreDernière intervention 7 janvier 2009
-
2 juin 2007 à 16:51
The_Guardian
Messages postés317Date d'inscriptionvendredi 25 mai 2007StatutMembreDernière intervention19 octobre 2007
-
2 juin 2007 à 18:23
Bonjour
Voila mon problème. En C j'ai une structure ayant comme élément un pointeur sur un tableau de structures. Comment faire le malloc et comment accéder au éléments.
The_Guardian
Messages postés317Date d'inscriptionvendredi 25 mai 2007StatutMembreDernière intervention19 octobre 20071 2 juin 2007 à 18:23
Salut
bien alors deja modifie un peu ta declaration pour avoir
struct My_Struct_Tab { ... };
donc pas de Mon_Tableau[100] pour le moment
puis tu fais struct My_Struct_Tab * monTableau;
monTableau = (struct My_Struct_Tab *)malloc(100*sizeof(struct My_Struct_Tab));
for (i=0; i<100; i++) {
monTableau[i].tab = (struct ST_Toto *)malloc(20*sizeof(struct ST_Toto));
}
Et au final tu pourras faire :
monTableau[50].tab[10].variable;