tableau de structure dynamique
Re,
Là j'ai creé un tableau dynamique
Code:
1 2 3 4 5 6
| struct tableauDynamique_struct
{
int *tab;
size_t taille;
size_t capacite;
}; |
où je vais stocker la listes de structure
Code:
1 2 3 4 5 6
| struct Dsequence
{
MotCompact *p2seq;
MotCompact *pMotGauche;
MotCompact *pMotDroit;
}; |
je trouve un probleme dans l'operation du remplissage du tableau :
en fait je parcours la table de hachage qui contient des paires de mots et là je dois remplir la structure par ces paire de mots
voilà la fonction où je bloque qui ajoute un element au tableau dynamique
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| int TableauDynamique_struct_ajouter(struct tableauDynamique_int *pThis,char *seq,char *pMotGauche,char *pMotDroit))
{
assert(pThis->taille <= pThis->capacite);
/* Agrandir le tableau si besoin est. */
if(pThis->taille == pThis->capacite)
{
size_t nouvelleCapacite = (pThis->capacite < 4 ? 4 : (size_t)(pThis->capacite*1.5));
if(realloc_int(&pThis->tab, nouvelleCapacite) >= 0)
{
pThis->capacite = nouvelleCapacite;
}
else
return -1;
}
/* ajouter */
pThis->tab[ pThis->taille++ ] = nouvelleValeur;
return 0;
} |
pour ajouter je vois pas quoi faire?:calim2:
des idées svp?
merci
|erreur: incompatible types in assignment
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| int TableauDynamique_struct_ajouter(struct TableauDynamique_struct *pThis, struct BiSequence const* pcNouveau)
{
assert(pThis->taille <= pThis->capacite);
/* Agrandir le tableau si besoin est. */
if(pThis->taille == pThis->capacite)
{
size_t nouvelleCapacite = (pThis->capacite < 4 ? 4 : (size_t)(pThis->capacite*1.5));
if(realloc_struct(&pThis->tab, nouvelleCapacite) >= 0)
{
pThis->capacite = nouvelleCapacite;
}
else
return -1;
}
pThis->tab[pThis->taille++] = *pcNouveau;
} |
Au niveau de la derniere instruction j'ai une erreur de type
|erreur: incompatible types in assignment
et là :
Code:
if(realloc_struct(&pThis->tab, nouvelleCapacite) >= 0)
attention : passing argument 1 of ‘realloc_struct’ from incompatible pointer type|
Une idée svp?
merci