IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C Discussion :

probleme de compilation :remplissage de la table de hachage


Sujet :

C

  1. #21
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Citation Envoyé par cyrine Voir le message
    Merci Medinoc
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    struct Chainon_fbtAllocator *pAlloc2seq = Chainon_CreateFbtAllocator(1000000);
    	struct Coord_fbtAllocator *pAllocCoord2seq = Coord_CreateFbtAllocator(1000000);
    ces deux lignes je touche pas? car je vois leurs utilité ici
    MErci
    Bonsoir Médinoc,
    apres un long travail, je viens de découvrir l cause de la non génération de mon fichier texte qui va contenir les mots : c'est le non remplissage de la table de hachage
    je vois pas trop
    une idée svp?
    merci

  2. #22
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Bonjour,
    bon là je refais le travail depuis le debut
    je vais faire une focntion qui va retourner un pointeur sur une structure table de hachage qui va contenir les 2 table de hacha ge remplie depuis le fichier.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    int TraiterFichier(char const *langue, int *pNbLignes)
    {
    	int iSeq;
    	int bEnregistrementOK = 1;
    	int nbLignes = 0;
    	TableHachageMot *DblTableHash;
    	TableHachageMot *DblTableHash2;
    	struct Chainon_fbtAllocator *pAlloc2seq = Chainon_CreateFbtAllocator(1000000);
    	struct Coord_fbtAllocator *pAllocCoord2seq = Coord_CreateFbtAllocator(1000000);
     
    	AfficherCarac(stdout, 79, '-');
    	printf("\nTraitement fichier pour langue : %s\n", langue);
     
    	if(pNbLignes != NULL)
    		*pNbLignes = 0;
    		*pMaxSequence = 0;
     
    	DblTableHash = CreerDoubleTableHachage();
    	DblTableHash2 = CreerDoubleTableHachage();
    	SetAllocateurChainon(Chainon_FbtAllocToIface(pAlloc2seq));
    	SetAllocateurCoord(Coord_FbtAllocToIface(pAllocCoord2seq));
    	if(LireFichierEntree(langue, DblTableHash, DblTableHash2 ,&nbLignes)<0)
    		return EXIT_FAILURE;
     
    	{
    		size_t *pStats = NULL;
    		size_t nStats = 0;
    		if(statistiques_double_table(DblTableHash, &pStats, &nStats)>=0)
    		{
    			#if 0
    			size_t iStat;
    			#endif
    			printf("--- Statistiques de la table de hachage ---\n");
    			while(nStats>0 && pStats[nStats-1]==0)
    				nStats--;
    			printf("Nb. de cases vides        : %llu\n", (long long)pStats[0]);
    			printf("Nb. maximum de collisions : %llu\n", (long long)nStats);
    			#if 0
    			for(iStat=0 ; iStat<nStats ; iStat++)
    			{
    				if(pStats[iStat]!=0)
    					printf("%llu : %llu\n", (long long)iStat, (long long)(pStats[iStat]));
    			}
    			#endif
    			putchar('\n');
    		}
    		free(pStats), pStats=NULL;
    	}
     
    	if(pNbLignes != NULL)
    		*pNbLignes = nbLignes;
     
    	printf("Calcul des nombres de lignes...\n");
    	CalculerNombreLignesDoubleTable(DblTableHash);
    	CalculerNombreLignesDoubleTable(DblTableHash2);
    	return (bEnregistrementOK ? EXIT_SUCCESS : EXIT_FAILURE);

  3. #23
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Citation Envoyé par cyrine Voir le message
    JE pense là qu'il faut creer avant une 2eme table de hachage pour contenir la liste des mots
    de cette façon?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    int TraiterFichier(char const *langue, int *pNbLignes)
    {
     
    	int bEnregistrementOK = 1;
    	int nbLignes = 0;
    	TableHachageMot *DblTableHash;
    	TableHachageMot *DblTableHash2;
    	struct Chainon_fbtAllocator *pAlloc2seq = Chainon_CreateFbtAllocator(1000000);
    	struct Coord_fbtAllocator *pAllocCoord2seq = Coord_CreateFbtAllocator(1000000);
     
    	AfficherCarac(stdout, 79, '-');
    	printf("\nTraitement fichier pour langue : %s\n", langue);
     
    	if(pNbLignes != NULL)
    		*pNbLignes = 0;
     
     
    	DblTableHash = CreerDoubleTableHachage();
    	DblTableHash2 = CreerDoubleTableHachage();
    	SetAllocateurChainon(Chainon_FbtAllocToIface(pAlloc2seq));
    	SetAllocateurCoord(Coord_FbtAllocToIface(pAllocCoord2seq));
    	if(LireFichierEntree(langue, DblTableHash,DblTableHash, &nbLignes)<0)
    		return EXIT_FAILURE;
    	/*EnregistrerTableCompleteFichBinaire(TableHash, langue, 2);*/
     
    	{
    		size_t *pStats = NULL;
    		size_t nStats = 0;
    		if(statistiques_double_table(DblTableHash, &pStats, &nStats)>=0)
    		{
    			#if 0
    			size_t iStat;
    			#endif
    			printf("--- Statistiques de la table de hachage ---\n");
    			while(nStats>0 && pStats[nStats-1]==0)
    				nStats--;
    			printf("Nb. de cases vides        : %llu\n", (long long)pStats[0]);
    			printf("Nb. maximum de collisions : %llu\n", (long long)nStats);
    			#if 0
    			for(iStat=0 ; iStat<nStats ; iStat++)
    			{
    				if(pStats[iStat]!=0)
    					printf("%llu : %llu\n", (long long)iStat, (long long)(pStats[iStat]));
    			}
    			#endif
    			putchar('\n');
    		}
    		free(pStats), pStats=NULL;
    	}
     
    	if(pNbLignes != NULL)
    		*pNbLignes = nbLignes;
     
    	printf("Calcul des nombres de lignes...\n");
    	CalculerNombreLignesDoubleTable(DblTableHash);
    	/*printf("La table de hachage avant le filtrage:\n");
    	dump_table(TableHash);*/
     
    	return (bEnregistrementOK ? EXIT_SUCCESS : EXIT_FAILURE);
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    int LireFichierEntree(char const *langue, TableHachageMot DblTableHash[],TableHachageMot DblTableHash2[],int *pNbLignes)
    {
    	int retour = -1;
    	FILE *fdesc = NULL;
    	if(pNbLignes != NULL)
    		*pNbLignes = 0;
    	fdesc = ouvrir_fichier_entree(langue);
    	if ( fdesc==NULL )
    	{
    		perror("fopen");
    	}
    	else
    	{
    		char* buff = NULL;
    		char* prec = NULL;
    		char* concat = NULL;
    		size_t tailleBuff = 0;
    		size_t taillePrec = 0;
    		size_t tailleConcat = 0;
    		int ancienneLigne = -1;
    		int ancienneColonne = -1;
    		int ligne = 0;
    		int colonne = -1;
    		ssize_t res;
     
    		printf("Lecture du fichier texte (prog: 1 point pour %d lignes)...\n", PROG_NBLIGNES);
    		while ( (res=get_word(fdesc, &buff, &tailleBuff, &ligne, &colonne))>0 )
    		{
    			if(ancienneLigne == ligne)
    			{
    				static char const separ[] = {SEPARATEUR, '\0'};
     
    				/* Mot sur la même ligne: Ajouter 2seq */
    				if(tailleConcat < 2*tailleBuff)
    				{
    					tailleConcat = 2*tailleBuff;
    					ReallocCharExit(&concat, tailleConcat);
    				}
    				assert(concat != NULL);
     
    				strcpyN(concat, tailleConcat, prec);
    				strcatN(concat, tailleConcat, separ);
    				strcatN(concat, tailleConcat, buff);
     
    				#if 0
    				AfficherEspaces(ancienneColonne);
    				puts(concat);
    				#endif
    				InsertionDoubleHashEx(DblTableHash, concat, ancienneLigne, ancienneColonne);
    				InsertionDoubleHashEx(DblTableHash2, buff, ancienneLigne, ancienneColonne);
     
    			}
    			else
    			{
    				if(ligne%PROG_NBLIGNES==0)
    					putchar('.');
    			}
     
    			/* Mémorise l'ancien mot et son n° de ligne */
    			ancienneLigne = ligne;
    			ancienneColonne = colonne;
    			/* Pour de meilleures performances,
    			  on bosse en double buffer plutot que recopier à chaque fois.*/
    			if(taillePrec != tailleBuff)
    			{
    				taillePrec = tailleBuff;
    				ReallocCharExit(&prec, taillePrec);
    			}
    			assert(prec != NULL);
    			assert(taillePrec == tailleBuff);
    			SwapPtrChar(&prec, &buff);
    		}/*while*/
     
    		if(res < 0)
    			perror("get_word");
    		else
    		{
    			retour = 0; /* OK */
    			putchar('\n');
    			printf("Lu %d lignes.\n", ligne);
    			if(pNbLignes != NULL)
    				*pNbLignes = ligne;
    		}
     
    		/* Nettoyage */
    		free(concat), concat=NULL, tailleConcat=0;
    		free(prec), prec=NULL, taillePrec=0;
    		free(buff), buff=NULL, tailleBuff=0;
    		fclose(fdesc), fdesc=NULL;
    	}/*if fdesc*/
    	return retour;
    }
    BOnsoir,
    là je me demande encore, je fais appel de la fonction TraiterFichier deux fois dans le main: une fois pour la langue francaise pour construire les 2 table de hachage, et une autre fois pour la langue anglais.
    Là je me demade si lors du 2eme appele les 2 ancienne table de hachage s'ecrasent . donc on aura à la fin 2 tables de hachage en anglais?
    Des reponses à ma question SVP?
    merci

  4. #24
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Le problème majeur, c'est que les tables de hachage sont perdues à la fin de la fonction TraiterFichier().

    De plus, tu passes deux fois la même table à la fonction LireFichierEntree(), au lieu de passer 1 et 2...

  5. #25
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Citation Envoyé par Médinoc Voir le message
    Le problème majeur, c'est que les tables de hachage sont perdues à la fin de la fonction TraiterFichier().

    .
    Merci Medinoc,
    Là je vois pas trop comment les conserver?
    t'as une idée svp?
    merci

  6. #26
    Membre émérite Avatar de SofEvans
    Homme Profil pro
    Développeur C
    Inscrit en
    Mars 2009
    Messages
    1 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur C

    Informations forums :
    Inscription : Mars 2009
    Messages : 1 078
    Points : 2 339
    Points
    2 339
    Par défaut
    Dans ton cas, il n'y a pas reellement le choix.

    Il faut declarer les pointeur non pas dans la fonction appelé mais dans la fonction appelante.
    Ainsi, tu fais un passage d'argument par adresse (un pointeur en gros), ce qui te permet de conserver tes variables.

    Donc :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    int main ()
    {
            ...
            TraiterFichier("francais", 50);
    }
     
    int TraiterFichier(char const *langue, int *pNbLignes)
    {
            .....
    	TableHachageMot *DblTableHash;
    	TableHachageMot *DblTableHash2;
            .....
    }
    Devient ceci (ou quelque chose de tres proche)




    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    int main ()
    {
             ...
    	TableHachageMot *DblTableHash = NULL;
    	TableHachageMot *DblTableHash2 = NULL;
            TraiterFichier(DblTableHash, DblTableHash2, "francais", 50);
    }
     
    int TraiterFichier(TableHachageMot *DblTableHash, TableHachageMot *DblTableHash2, char const *langue, int *pNbLignes)
    {
            .....
    }

    Un conseil, n'oublie pas d'initialiser tout le temps tes pointeurs ! A la bonne adresse si tu la connais, sinon a NULL.

  7. #27
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Merci SoftEavans,
    Comme d'habitude avec tes reponses efficaces
    Amitiés
    Cyrine

  8. #28
    Membre émérite Avatar de SofEvans
    Homme Profil pro
    Développeur C
    Inscrit en
    Mars 2009
    Messages
    1 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur C

    Informations forums :
    Inscription : Mars 2009
    Messages : 1 078
    Points : 2 339
    Points
    2 339
    Par défaut
    Merci cyrine, mais je n'ai fait qu'exprimer ce que Médinoc disait.

  9. #29
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    NOTE: Plutôt que les mettre à NULL dans le main, appeler la fonction de création dedans (au lieu de le faire dans TraiterFichier()).

  10. #30
    Membre émérite Avatar de SofEvans
    Homme Profil pro
    Développeur C
    Inscrit en
    Mars 2009
    Messages
    1 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur C

    Informations forums :
    Inscription : Mars 2009
    Messages : 1 078
    Points : 2 339
    Points
    2 339
    Par défaut
    Un conseil, n'oublie pas d'initialiser tout le temps tes pointeurs ! A la bonne adresse si tu la connais, sinon a NULL.
    Effectivement, on peut faire l'allocation dynamique directement, je n'avais pas vu la ligne.
    C'est bien meilleur que de mettre NULL, merci Médinoc.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    int main ()
    {
             ...
    	TableHachageMot *DblTableHash = CreerDoubleTableHachage();
    	TableHachageMot *DblTableHash2 = CreerDoubleTableHachage();
     
            TraiterFichier(DblTableHash, DblTableHash2, "francais", 50);
    }
     
    int TraiterFichier(TableHachageMot *DblTableHash, TableHachageMot *DblTableHash2, char const *langue, int *pNbLignes)
    {
            .....
    }

    Cyrine << Tu declare deux table de hachage, mais tu n'en voulait qu'une a la fin ? Si la deuxieme table est delarer juste temporairement afin de remplir ou faire des operation sur la premiere, une maniere plus propre et plus logique serait de la declarer dans TraiterFichier.


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
     
    int main ()
    {
             ...
            /* On ne veut conserver QUE la premiere table */
    	TableHachageMot *DblTableHash = CreerDoubleTableHachage();
     
            TraiterFichier(DblTableHash, "francais", 50);
    }
     
    int TraiterFichier(TableHachageMot *DblTableHash, char const *langue, int *pNbLignes)
    {
            /* La table sera perdu a la fin */
            TableHachageMot *DblTableHash2 = CreerDoubleTableHachage();
            .....
     
            /* Ne pas oublier de liberer la memoire pour DblTableHash2 */
    }

  11. #31
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Merci SoftEavans et Médinoc, en fait j' veux les deux table de hachage: pour stoker les mots et l'autre pour stocker les couple de mots.

  12. #32
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    Là j'ai un probleme, apres le remplissage des table de hachage, j'ai voulu parcourir chacun pour afficher le contenu, mais là il n'affiche rien comme si la table est vide
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    int main(int argc, char *argv[])
    {
    int i,j;
        TableHachageMot *DblTableHash1en = CreerDoubleTableHachage();
    	TableHachageMot *DblTableHash2en = CreerDoubleTableHachage();
        TableHachageMot *DblTableHash1fr = CreerDoubleTableHachage();
    	TableHachageMot *DblTableHash2fr = CreerDoubleTableHachage();
    	int nbLignes1=0;
    		#ifdef _MSC_VER
    	{
    		int tmpFlag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
    		tmpFlag |= _CRTDBG_CHECK_ALWAYS_DF;
    		_CrtSetDbgFlag( tmpFlag );
    	}
    	#endif
    
    if(TraiterFichier(DblTableHash1fr, DblTableHash2fr, "fr", &nbLignes1)!=EXIT_SUCCESS)
    		return EXIT_FAILURE;
    printf("génération  des triggers    inter-langues");
    
    for(i=0;i<TAILLEHASH;i++)
    {
           printf("%s",GetMot(DblTableHash2fr[i]));
    
    }
    
    return EXIT_SUCCESS;
    }
    une idée svp?
    merci

  13. #33
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Il compile sans warning, cet appel à GetMot()?
    Tu as une double table de hachage, c'est donc un tableau de tableux de listes chaînées. Là, tu ne fais qu'une seule boucle...

  14. #34
    Membre émérite Avatar de SofEvans
    Homme Profil pro
    Développeur C
    Inscrit en
    Mars 2009
    Messages
    1 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur C

    Informations forums :
    Inscription : Mars 2009
    Messages : 1 078
    Points : 2 339
    Points
    2 339
    Par défaut
    Comme l'a dit Médinoc, il nous faudrait GetMot(), mais ca semble deja louche a la base.

    Il faut que tu configure le compilo C avec au minimum [-W] et [-Wall].

    EDIT

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    for(i=0;i<TAILLEHASH;i++)
    {
           printf("%s",GetMot(DblTableHash2fr[i]));
     
    }
    Avec DblTableHash2fr[i], c'est une ADRESSE que tu envoie, plus precisement l'adresse qui pointe sur la premiere case d'un tableau. Il ne faut pas faire "%s" la dessus !.

  15. #35
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Note pour ceux qui ne savent pas: La table de hachage est double car elle hache les mots selon deux clés différentes; vu qu'il n'y a pas de comptage de références, il était plus facile de les mettre bout-à-bout que de faire deux tables de hachage semi-indépendantes. De plus, la clé de la première table est incluse dans celle de la seconde.

    (sur demande, je peux ajouter un schéma)

  16. #36
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    il m'affiche en plus une erreur là :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    printf("%s",GetMot(DblTableHash2fr[i][j]));
    /home/cyrine/Bureau/projet Final/projet version 11 Juin/main.c|983|erreur: incompatible type for argument 1 of ‘GetMot’|
    voilà la fonction :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    char const * GetMot(ChainonMot const *pc)
    {
    	assert(pc!=NULL);
    	return pc->mot;
    }

  17. #37
    Membre émérite Avatar de SofEvans
    Homme Profil pro
    Développeur C
    Inscrit en
    Mars 2009
    Messages
    1 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur C

    Informations forums :
    Inscription : Mars 2009
    Messages : 1 078
    Points : 2 339
    Points
    2 339
    Par défaut
    Pourrait-on avoir le code reproduit l'erreur (la boucle je pense) ainsi que le code de GetMot() s'il te plait ?
    Car tel quel, le compilo nous informe qu'il y a incompatibilité entre les types passer, et on peut pas t'eclairer tant qu'on ne voit pas ce que tu as coder.

    EDIT : désolé, je n'avais pas vu (tu n'aurai pas editer par hasard ?)

    Desolé, je ne retrouve pas la definition de la structure "TableHachageMot" et celle de "ChainonMot". Pourrai tu les mettre s'il te plait ?

  18. #38
    Débutant Avatar de étoile de mer
    Profil pro
    Étudiant
    Inscrit en
    Avril 2007
    Messages
    978
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2007
    Messages : 978
    Points : 117
    Points
    117
    Par défaut
    ok , merci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    typedef struct st_chainonMot ChainonMot;
     
    typedef struct st_liste
    {
    	ChainonMot *pPremier;
    } ListeMot;
     
    typedef ListeMot TableHachageMot[TAILLEHASH];
     
    struct st_chainonMot
    {
    	struct st_chainonMot *suivant;
    	int nbLignes;
    	size_t cchTailleMot;
    	ListeCoord coords;
    	char mot[1];
    };

  19. #39
    Membre émérite Avatar de SofEvans
    Homme Profil pro
    Développeur C
    Inscrit en
    Mars 2009
    Messages
    1 078
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur C

    Informations forums :
    Inscription : Mars 2009
    Messages : 1 078
    Points : 2 339
    Points
    2 339
    Par défaut
    Oula !

    C'est un peu confu dans ma tete.

    Voici ta structure ChainonMot
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    typedef struct st_chainonMot ChainonMot;
    struct st_chainonMot
    {
    	struct st_chainonMot *suivant;
    	int nbLignes;
    	size_t cchTailleMot;
    	ListeCoord coords;
    	char mot[1];
    };
    Le truc qui m'as sauté aux yeux, c'est : char mot[1];

    Tu declare un tableau statique de char, tableau qui contient ... UNE case ???
    Pourquoi ?
    Pourquoi ne pas mettre le plus simplement du monde char mot; ???
    De plus, cela me semble mal nommé.

    J'ai l'impression que tu as fait une liste simplement chainée
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    struct st_chainonMot
    {
    	struct st_chainonMot *suivant;
            ....
    }
    Donc, si on parcours la liste du debut jusqu'a la fin, on obtient quoi ?
    Un seul mot ? Ou chaque structure contient un mot d'une lettre ??

    En tout les cas, l'erreur provient d'ici :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     char const * GetMot(ChainonMot const *pc)
    {
    	assert(pc!=NULL);
    	return pc->mot;
    }
    Si tu regarde mieux ta structure, on a :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    struct st_chainonMot
    {
    	struct st_chainonMot *suivant;
    	int nbLignes;
    	size_t cchTailleMot;
    	ListeCoord coords;
    	char mot[1];
    };

    Le type de mot est le type du return ne sont pas les meme (char[] vs char).
    Il y a plusieurs moyen d'y remedier, mais je t'encourage et repenser fortmement a ta structure de base, car si celle-ci n'est pas absolu compris, clair et defendable, ben le reste ca va etre coton ....

  20. #40
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 381
    Points : 41 582
    Points
    41 582
    Par défaut
    Essaie un code de ce style:
    Code C : Sélectionner tout - Visualiser dans une fenêtre à part
    printf("%s", GetMot(GetPremierC(&DblTableHash2fr[i][j])) );

    Ou, en plus développé, affichant toute la liste:
    Code C : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    ListeMot const * pListe = &DblTableHash2fr[i][j];
    ChainonMot const * pcMot;
    for(pcMot = GetPremierC(pListe) ; pcMot!=NULL ; pcMot = GetSuivantC(pcMot))
    	printf("%s", GetMot(pcMot));

Discussions similaires

  1. probleme lors de remplissage d'un table JTable
    Par foufoulina2007 dans le forum Composants
    Réponses: 7
    Dernier message: 02/11/2007, 18h13
  2. [JSP & TAGLIB] Probleme de compilation
    Par GesMo dans le forum Servlets/JSP
    Réponses: 7
    Dernier message: 17/05/2004, 15h03
  3. Probleme de Compilation de la STL
    Par stoluup dans le forum MFC
    Réponses: 3
    Dernier message: 05/05/2004, 17h25
  4. [TP]Probleme de compilation sous TP7
    Par yffick dans le forum Turbo Pascal
    Réponses: 7
    Dernier message: 18/12/2003, 20h32
  5. Problemes de compilation avec g++ sous linux
    Par Selimmel dans le forum Autres éditeurs
    Réponses: 3
    Dernier message: 19/09/2003, 13h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo