Pb de compilation

Résolu
tomalille Messages postés 52 Date d'inscription jeudi 16 juin 2005 Statut Membre Dernière intervention 5 juin 2007 - 22 nov. 2005 à 20:17
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019 - 22 nov. 2005 à 20:47
Bonjour j'ai un petit problème de compilation. J'utilise un struct qui contient lui même un tableau d'int et je ne comprends pas pourquoi j'ai une erreur de compilation:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>


#define NBOPTION 5
#define NBCATEGORIE 6


struct CATEGORIE{
int indiceCategorie;
int nombre;
int option[NBOPTION];
int priorite;
};


struct COEFFICIENT{
int indiceCoef;
float coef;
};


int main(void)
{
int i = 0;
int j = 0;
float k = 0;
float l = 0;
float temp = 0;
struct COEFFICIENT coef[NBOPTION];
struct CATEGORIE cat[NBCATEGORIE];


//lecture des coefficients


coef[0].indiceCoef=1;
coef[0].coef = 1.0 / 2.0;


coef[1].indiceCoef=2;
coef[1].coef = 2.0 / 3.0;


coef[2].indiceCoef=3;
coef[2].coef = 1.0 / 3.0;


coef[3].indiceCoef=4;
coef[3].coef = 2.0 / 5.0;


coef[4].indiceCoef=5;
coef[4].coef = 1.0 / 5.0;

// for(i=0;i<NBOPTION;i++)
// {
// printf("\n %e \n",coef[i].coef);
// }


//lecture des catégories


cat[0].indiceCategorie = 1;
cat[0].nombre = 1;
cat[0].option = {1,0,1,1,0};


cat[1].indiceCategorie = 2;
cat[1].nombre = 1;
cat[1].option = {0,0,0,1,0};


cat[2].indiceCategorie = 3;
cat[2].nombre = 2;
cat[2].option = {0,1,0,0,1};


cat[3].indiceCategorie = 4;
cat[3].nombre = 2;
cat[3].option = {0,1,0,0,1};


cat[4].indiceCategorie = 5;
cat[4].nombre = 2;
cat[4].option = {1,0,1,0,0};


cat[5].indiceCategorie = 6;
cat[5].nombre = 2;
cat[5].option = {1,1,0,0,0};


return 0;
}

1 réponse

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
22 nov. 2005 à 20:47
cat[4].option[0] = valeur; les autres idem

ciao...
http://dev.winsysdev.com
BruNews, MVP VC++
3
Rejoignez-nous