Bonjour,
j'ai un petit pb avec mes structs. je vous explique: je definis un
struct en globale pour l'utiliser dans une procedure qui lit des
donnees a partir d'un fichier.
Dans ce struct j'ai un tableau d'un autre struct dont la capacite est defini automatiquement.
Voici ce que j'ai fait:
struct NOEUDS{
int numNoeuds;
int coordX;
int coordY;
int nbInterfaces;
int coutSlots;
int nbTypes;
int *interfaces;
};
struct INTERFACENOEUD{
int nbCanaux;
int prix;
};
void lectureNoeuds(struct NOEUDS *noeuds,struct INTERFACENOEUD *interfaces)
{
int i;
tempNoeuds[i]=malloc(sizeof(int)*4);
for(i=0;i<nbNoeuds;i++)
{
fscanf(fichierEntree,"%d",&noeuds[i].numNoeuds);
fscanf(fichierEntree,"%d",&noeuds[i].coordX);
fscanf(fichierEntree,"%d",&noeuds[i].coordY);
fscanf(fichierEntree,"%d",&noeuds[i].nbInterfaces);
fscanf(fichierEntree,"%d",&noeuds[i].coutSlots);
fscanf(fichierEntree,"%d",&noeuds[i].nbTypes);
interfaces[i] = malloc(sizeof(struct INTERFACENOEUD) * noeuds[i].nbTypes);
for(j<0;j<noeuds[i].nbTypes;j++)
{
fscanf(fichierEntree,"%d",&interfaces[i][j].nbCanaux);
fscanf(fichierEntree,"%d",&interfaces[i][j].prix);
}
}
}
J'ai alors une erreur a la compilation l'allocation de la memoire