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 :

Affichage du contenu d'une liste chainée


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé 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
    Par défaut Affichage du contenu d'une liste chainée
    Bonjour,
    J'ai un probleme, ( je developpe en C)
    j'ai une fonction qui parcourt toute la liste chainee qui contient des mots , jai reussi à faire l'affichage de la liste mais le probleme c'est qu'il n ya pas un espace entre les differents mot
    exple il affiche "lebateau " au lieu du "le bateau".
    j'attends vos reponse.
    merci

  2. #2
    Expert confirmé
    Avatar de diogene
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Juin 2005
    Messages
    5 761
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 761
    Par défaut
    Voyons, sans une ligne de code, comment veux-tu qu'on puisse deviner ?
    Si le code est donné dans un autre post, met un lien ou au moins le titre de cette discussion.

  3. #3
    Membre émérite
    Inscrit en
    Juillet 2005
    Messages
    512
    Détails du profil
    Informations forums :
    Inscription : Juillet 2005
    Messages : 512
    Par défaut
    le probleme c'est qu'il n ya pas un espace entre les differents mot
    Et bien tu l'ajoute lors de l'affichage.

    Je suppose qu'un maillon contient un mot !

  4. #4
    Membre éclairé 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
    Par défaut re
    Citation Envoyé par Lucien63 Voir le message
    Et bien tu l'ajoute lors de l'affichage.

    Je suppose qu'un maillon contient un mot !
    cbien ça chaque maillon contient un mot

  5. #5
    Expert éminent
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Par défaut
    Citation Envoyé par cyrine Voir le message
    j'ai une fonction qui parcourt toute la liste chainee qui contient des mots , jai reussi à faire l'affichage de la liste mais le probleme c'est qu'il n ya pas un espace entre les differents mot
    exple il affiche "lebateau " au lieu du "le bateau".
    j
    C'est peut être à toi d'ajouter l'espace, tu ne crois pas ?

    Arf ! Grillaid...

    Montre ton code.

  6. #6
    Membre éclairé 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
    Par défaut re
    Citation Envoyé par Emmanuel Delahaye Voir le message
    C'est peut être à toi d'ajouter l'espace, tu ne crois pas ?

    Arf ! Grillaid...

    Montre ton code.
    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
     
     
    int main()
    {
      FILE *F;
      char mot[100];
      int i;
      unsigned int cle,pt;
      int nl, pos;
      nl=pos=1;
      char c;
      int seuil;
      Liste **L;
     
      Liste **TableHash;
      TableHash = (Liste **) malloc (TAILLEHASH * sizeof(Liste *));
      for(i=0;i<TAILLEHASH;++i)
        TableHash[i] = NULL;
     
      pt=hash_cle(".");
      //printf("%d",pt);
     
      printf("debut du programme \n----------------------------------\n");  
      F=fopen("C:\\Documents and Settings\\siril\\Bureau\\projet\\text.txt","r");
      while(fscanf(F,"%s",mot)==1){
           cle = hash_cle(mot);
          if ((cle!=pt ) && (! ChercherMotDansTableHash(TableHash,mot)))
                TableHash[cle] = InsertionEnTete(TableHash[cle],mot);     
      }
      fclose(F );
      F=fopen("C:\\Documents and Settings\\siril\\Bureau\\projet\\text.txt","r");
      PosLigne(F,TableHash);
     
      //filtrage 
      printf("\nla liste filtre :\n----------------------------------\n");
      FiltreListe(TableHash,2);
      AfficherTableHash(TableHash);
     
      //géneration des 2seq
      Liste *seq=NULL;
      Generer2seq(TableHash, 2, &seq);
      printf("\nla liste des 2seq :\n----------------------------------\n");
      AfficherListe(seq);
     
      scanf("%c",c);
     
      return 0;
    }
     
     
    void AfficherListe(Liste *L){
      Liste *p;
      for(p=L;p!=NULL;p=p->suivant){
        AfficheMot(p->mot);
        AfficherCoordonnees(p->c);
      }
    }
     
     
    void AfficheMot(char *mot){
      printf("%s ",mot);
    }
    voilà

  7. #7
    Expert éminent
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Par défaut
    Citation Envoyé par cyrine Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    void AfficheMot(char *mot){
      printf("%s ",mot);
    }
    Cette fonction devrait afficher les mots séparés par un ' '. Elle est bien appelée ?

    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
     
     
    -------------- Build: Debug in hello ---------------
     
    Compiling: main.c
    C:\dev\hello\main.c:3: warning: function declaration isn't a prototype
    C:\dev\hello\main.c: In function `main':
    C:\dev\hello\main.c:4: error: `FILE' undeclared (first use in this function)
    C:\dev\hello\main.c:4: error: (Each undeclared identifier is reported only once
    C:\dev\hello\main.c:4: error: for each function it appears in.)
    C:\dev\hello\main.c:4: error: `F' undeclared (first use in this function)
    C:\dev\hello\main.c:12: error: `Liste' undeclared (first use in this function)
    C:\dev\hello\main.c:12: error: `L' undeclared (first use in this function)
    C:\dev\hello\main.c:14: error: `TableHash' undeclared (first use in this function)
    C:\dev\hello\main.c:15: error: syntax error before ')' token
    C:\dev\hello\main.c:16: error: `TAILLEHASH' undeclared (first use in this function)
    C:\dev\hello\main.c:17: error: `NULL' undeclared (first use in this function)
    C:\dev\hello\main.c:19: warning: implicit declaration of function `hash_cle'
    C:\dev\hello\main.c:20: error: syntax error before '/' token
    C:\dev\hello\main.c:22: warning: implicit declaration of function `printf'
    C:\dev\hello\main.c:23: warning: implicit declaration of function `fopen'
    C:\dev\hello\main.c:24: warning: implicit declaration of function `fscanf'
    C:\dev\hello\main.c:26: warning: implicit declaration of function `ChercherMotDansTableHash'
    C:\dev\hello\main.c:27: warning: implicit declaration of function `InsertionEnTete'
    C:\dev\hello\main.c:29: warning: implicit declaration of function `fclose'
    C:\dev\hello\main.c:31: warning: implicit declaration of function `PosLigne'
    C:\dev\hello\main.c:33: error: syntax error before '/' token
    C:\dev\hello\main.c:35: warning: implicit declaration of function `FiltreListe'
    C:\dev\hello\main.c:36: warning: implicit declaration of function `AfficherTableHash'
    C:\dev\hello\main.c:38: error: syntax error before '/' token
    C:\dev\hello\main.c:38: error: stray '\233' in program
    C:\dev\hello\main.c:38:20: invalid suffix "seq" on integer constant
    C:\dev\hello\main.c:40: warning: implicit declaration of function `Generer2seq'
    C:\dev\hello\main.c:40: error: `seq' undeclared (first use in this function)
    C:\dev\hello\main.c:42: warning: implicit declaration of function `AfficherListe'
    C:\dev\hello\main.c:44: warning: implicit declaration of function `scanf'
    C:\dev\hello\main.c:44: warning: format argument is not a pointer (arg 2)
    C:\dev\hello\main.c:11: warning: unused variable `seuil'
    C:\dev\hello\main.c: At top level:
    C:\dev\hello\main.c:50: error: syntax error before '*' token
    C:\dev\hello\main.c:50: warning: function declaration isn't a prototype
    C:\dev\hello\main.c:50: error: conflicting types for 'AfficherListe'
    C:\dev\hello\main.c:42: error: previous implicit declaration of 'AfficherListe' was here
    C:\dev\hello\main.c: In function `AfficherListe':
    C:\dev\hello\main.c:51: error: `Liste' undeclared (first use in this function)
    C:\dev\hello\main.c:51: error: `p' undeclared (first use in this function)
    C:\dev\hello\main.c:52: error: `L' undeclared (first use in this function)
    C:\dev\hello\main.c:52: error: `NULL' undeclared (first use in this function)
    C:\dev\hello\main.c:53: warning: implicit declaration of function `AfficheMot'
    C:\dev\hello\main.c:54: warning: implicit declaration of function `AfficherCoordonnees'
    C:\dev\hello\main.c: At top level:
    C:\dev\hello\main.c:59: error: conflicting types for 'AfficheMot'
    C:\dev\hello\main.c:53: error: previous implicit declaration of 'AfficheMot' was here
    Process terminated with status 1 (0 minutes, 0 seconds)
    25 errors, 19 warnings
    On peut avoir la version compilable ?

  8. #8
    Membre chevronné Avatar de KindPlayer
    Profil pro
    Inscrit en
    Février 2007
    Messages
    471
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 471
    Par défaut suggestion
    dans ta fonction AfficherListe tu peux rajouter printf(" "); apres l'appel à AfficherMot

  9. #9
    Expert éminent
    Avatar de Emmanuel Delahaye
    Profil pro
    Retraité
    Inscrit en
    Décembre 2003
    Messages
    14 512
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Retraité

    Informations forums :
    Inscription : Décembre 2003
    Messages : 14 512
    Par défaut
    Citation Envoyé par KindPlayer Voir le message
    dans ta fonction AfficherListe tu peux rajouter printf(" "); apres l'appel à AfficherMot
    Pourquoi ? Il y a déjà un espace dans le formatage de printf(). Tu ne le vois pas ?

Discussions similaires

  1. Problème affichage d'une liste chainée
    Par Nardjesse dans le forum Débuter
    Réponses: 8
    Dernier message: 06/01/2013, 11h51
  2. Réponses: 0
    Dernier message: 13/12/2010, 09h34
  3. Affichage du contenu d'une AWT List
    Par NaZeF dans le forum Interfaces Graphiques en Java
    Réponses: 2
    Dernier message: 02/03/2010, 11h34
  4. Réponses: 12
    Dernier message: 03/07/2008, 13h53
  5. manipulation d'une liste chainé
    Par sorari dans le forum C++
    Réponses: 1
    Dernier message: 16/03/2005, 12h32

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