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

Linux Discussion :

debuggage de mon prog


Sujet :

Linux

  1. #1
    Membre régulier
    Homme Profil pro
    Débutant
    Inscrit en
    Mai 2007
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Débutant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2007
    Messages : 58
    Points : 100
    Points
    100
    Par défaut bug ds mon prog
    http://membres.lycos.fr/mouezapetero/tpPoub.tar.gz

    3
    5
    abc

    ça fait une erreur de segmentation, et même avec gdb je ne sais pas pourquoi je ne peux pas modifier des pointeurs qui ont une adresse differente de 0 ou qui ont une adresse valide grace à mes malloc

    Pourquoi ça ne marche pas ?

  2. #2
    En attente de confirmation mail Avatar de gandalfar
    Inscrit en
    Novembre 2004
    Messages
    145
    Détails du profil
    Informations forums :
    Inscription : Novembre 2004
    Messages : 145
    Points : 141
    Points
    141
    Par défaut
    deja quand ta premiere fonction c 'est du grand n importe quoi

    Code c : 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
     
    void affichTabGen(char * tab)
    {
      printf("\nlbl821 affichTabGen:");
      {
        int cpt=0;
        while((tab[cpt]!= '\0'))
          {
    	printf("%s",tab[cpt]); //la tu considere tout les char qui passe comme des char *
     
    	cpt++;
     
          } 
      }
      printf("\nlbl825 :affichTabGen ***********FIN");
    }

    alors qu il suffit de faire un

    Code c : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    void affichTabGen(char * tab)
    {
        int cpt=0;
        printf("\nlbl821 affichTabGen:");
        printf("%s",tab);
        printf("\nlbl825 :affichTabGen ***********FIN");
    }

    ou un

    Code c : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    void affichTabGen(char * tab)
    {
        int cpt=0;
        printf("\nlbl821 affichTabGen:");
        while(tab[cpt] != '\0')
          printf("%c", tab[cpt++]);
        printf("%s",tab);
        printf("\nlbl825 :affichTabGen ***********FIN");
    }

    par contre je refuse de lire des fonction comme ton main car c est vraiment tres moche

  3. #3
    Membre régulier
    Homme Profil pro
    Débutant
    Inscrit en
    Mai 2007
    Messages
    58
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Débutant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2007
    Messages : 58
    Points : 100
    Points
    100
    Par défaut
    C'est vrai qu'il suffit d'afficher directement la chaine , merci.

    Alors pas d'dée pour l'erreur de segmentation ?

  4. #4
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    Je veux bien t'aider mais à condition que tu corriges tes erreurs :

    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
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    main.c:36: attention : no previous prototype for «affichTabGen"
    main.c: In function «affichTabGen":
    main.c:42: attention : format «%s" expects type «char *", but argument 2 has type «int"
    main.c: Hors de toute fonction :
    main.c:53: attention : function declaration isn"t a prototype
    main.c:122: attention : no previous prototype for «affichRegl"
    main.c: In function «affichRegl":
    main.c:131: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c: Hors de toute fonction :
    main.c:139: attention : no previous prototype for «affichStruct"
    main.c: In function «affichStruct":
    main.c:154: attention : format «%i" expects type «int", but argument 2 has type «struct Kase1Regl *"
    main.c:154: attention : format «%i" expects type «int", but argument 5 has type «Kase1Regl_p"
    main.c:154: attention : format «%i" expects type «int", but argument 9 has type «struct Kase1Regl *"
    main.c:169: attention : format «%i" expects type «int", but argument 2 has type «struct Kase1Regl *"
    main.c:169: attention : format «%i" expects type «int", but argument 5 has type «Kase1Regl_p"
    main.c:169: attention : format «%i" expects type «int", but argument 9 has type «struct Kase1Regl *"
    main.c: Hors de toute fonction :
    main.c:178: attention : function declaration isn"t a prototype
    main.c:184: attention : no previous prototype for «inserFitRuleDeb"
    main.c: In function «inserFitRuleDeb":
    main.c:208: erreur: «ptr2FitRulle3" undeclared (first use in this function)
    main.c:208: erreur: (Each undeclared identifier is reported only once
    main.c:208: erreur: for each function it appears in.)
    main.c: Hors de toute fonction :
    main.c:224: attention : no previous prototype for «epissagDebRegl"
    main.c: In function «epissagDebRegl":
    main.c:230: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c:231: attention : format «%i" expects type «int", but argument 2 has type «struct Kase1Regl *"
    main.c:234: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c:235: attention : format «%i" expects type «int", but argument 2 has type «struct Kase1Regl *"
    main.c: Hors de toute fonction :
    main.c:244: attention : no previous prototype for «epissagFinRegl"
    main.c: In function «epissagFinRegl":
    main.c:252: attention : trop d'arguments pour le format
    main.c:273: attention : trop d'arguments pour le format
    main.c: Hors de toute fonction :
    main.c:292: attention : no previous prototype for «epissagDebLettre"
    main.c: In function «epissagDebLettre":
    main.c:298: attention : format «%i" expects type «int", but argument 2 has type «KaseLettre_p"
    main.c:299: attention : format «%i" expects type «int", but argument 2 has type «struct Kasettr *"
    main.c:300: attention : assignment from incompatible pointer type
    main.c:302: attention : format «%i" expects type «int", but argument 2 has type «KaseLettre_p"
    main.c:303: attention : format «%i" expects type «int", but argument 2 has type «struct KaseLettr *"
    main.c: Hors de toute fonction :
    main.c:312: attention : no previous prototype for «epissagFinLettre"
    main.c: In function «epissagFinLettre":
    main.c:320: attention : trop d'arguments pour le format
    main.c:336: attention : assignment from incompatible pointer type
    main.c:341: attention : trop d'arguments pour le format
    main.c: Hors de toute fonction :
    main.c:358: attention : no previous prototype for «stringToTab"
    main.c:371: attention : function declaration isn"t a prototype
    main.c: In function «nettoieCommentaires":
    main.c:371: attention : type of «nLignes" defaults to «int"
    main.c: Hors de toute fonction :
    main.c:380: attention : no previous prototype for «afficheTablDim2"
    main.c:398: attention : no previous prototype for «posChn"
    main.c:433: attention : function declaration isn"t a prototype
    main.c:438: attention : no previous prototype for «nettoieEnlvLign"
    main.c: In function «nettoieEnlvLign":
    main.c:442: attention : unused variable «cpt4"
    main.c: Hors de toute fonction :
    main.c:475: attention : no previous prototype for «tail"
    main.c: In function «tail":
    main.c:477: attention : unused variable «b"
    main.c: Hors de toute fonction :
    main.c:489: attention : no previous prototype for «givLghMot"
    main.c:500: attention : no previous prototype for «copyApartir"
    main.c:505: attention : no previous prototype for «givMultiEspac"
    main.c:516: attention : no previous prototype for «strToStructuredRegl"
    main.c:522: attention : no previous prototype for «nettoieRemplaceVariabl"
    main.c:530: attention : function declaration isn"t a prototype
    main.c:550: attention : no previous prototype for «nbFitRules"
    main.c: In function «nbFitRules":
    main.c:550: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c:551: attention : format «%i" expects type «int", but argument 2 has type «struct Kase1Regl *"
    main.c:553: attention : format «%i" expects type «int", but argument 2 has type «struct Kase1Regl *"
    main.c: Hors de toute fonction :
    main.c:584: attention : no previous prototype for «splitLigne"
    main.c:601: attention : function declaration isn"t a prototype
    main.c: In function «main":
    main.c:624: attention : assignment discards qualifiers from pointer target type
    main.c:693: attention : format «%i" expects type «int", but argument 2 has type «Kase_p"
    main.c:696: attention : format «%i" expects type «int", but argument 2 has type «Kase_p"
    main.c:702: attention : format «%i" expects type «int", but argument 2 has type «struct Kase *"
    main.c:709: attention : format «%i" expects type «int", but argument 2 has type «Kase_p"
    main.c:721: attention : format «%i" expects type «int", but argument 2 has type «Kase_p"
    main.c:721: attention : format «%i" expects type «int", but argument 3 has type «Kase_p"
    main.c:723: attention : format «%i" expects type «int", but argument 2 has type «Kase_p"
    main.c:759: attention : format «%i" expects type «int", but argument 2 has type «Kase_p"
    main.c:761: attention : format «%i" expects type «int", but argument 2 has type «Kase_p"
    main.c:815: attention : passing argument 2 of «stringToTab" discards qualifiers from pointer target type
    main.c:851: attention : passing argument 3 of «__builtin_strncpy" as unsigned due to prototype
    main.c:863: attention : passing argument 3 of «__builtin_strncpy" as unsigned due to prototype
    main.c:899: attention : passing argument 2 of «stringToTab" discards qualifiers from pointer target type
    main.c:937: attention : passing argument 3 of «__builtin_strncpy" as unsigned due to prototype
    main.c:949: attention : passing argument 3 of «__builtin_strncpy" as unsigned due to prototype
    main.c:986: attention : parenthèses suggérées autour de l'affectation utilisée comme valeur de vérité
    main.c:1059: attention : passing argument 3 of «__builtin_strncpy" as unsigned due to prototype
    main.c:1071: attention : passing argument 3 of «__builtin_strncpy" as unsigned due to prototype
    main.c:1152: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c:1154: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c:1167: attention : declaration of «c" shadows a previous local
    main.c:633: attention : déclaration est masquée ici
    main.c:1200: attention : assignment from incompatible pointer type
    main.c:1215: attention : format «%i" expects type «int", but argument 2 has type «KaseLettre_p"
    main.c:1218: attention : assignment from incompatible pointer type
    main.c:1219: attention : assignment from incompatible pointer type
    main.c:1222: attention : assignment from incompatible pointer type
    main.c:1236: attention : declaration of «cpt" shadows a previous local
    main.c:608: attention : déclaration est masquée ici
    main.c:1274: attention : format «%i" expects type «int", but argument 2 has type «struct Kase1Regl *"
    main.c:1296: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c:1298: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c:1316: attention : trop peu d'arguments dans le format
    main.c:1323: attention : format «%i" expects type «int", but argument 2 has type «struct Kase1Regl *"
    main.c:1349: attention : format «%i" expects type «int *", but argument 2 has type «int"
    main.c:1363: attention : format «%i" expects type «int *", but argument 2 has type «int"
    main.c:1364: attention : chaîne de format de longueur nulle printf
    main.c:1167: attention : unused variable «c"
    main.c:1405: attention : initialization discards qualifiers from pointer target type
    main.c:1415: attention : passing argument 1 of «posChn" discards qualifiers from pointer target type
    main.c:1415: attention : passing argument 2 of «posChn" discards qualifiers from pointer target type
    main.c:1420: attention : declaration of «poub" shadows a previous local
    main.c:608: attention : déclaration est masquée ici
    main.c:1431: attention : passing argument 1 of «nettoieEnlvLign" discards qualifiers from pointer target type
    main.c:1432: attention : passing argument 1 of «givLghMot" discards qualifiers from pointer target type
    main.c:1433: attention : passing argument 1 of «givMultiEspac" discards qualifiers from pointer target type
    main.c:1440: attention : passing argument 1 of «tail" discards qualifiers from pointer target type
    main.c:1456: attention : passing argument 2 of «stringToTab" discards qualifiers from pointer target type
    main.c:1491: attention : passing argument 3 of «__builtin_strncpy" as unsigned due to prototype
    main.c:1503: attention : passing argument 3 of «__builtin_strncpy" as unsigned due to prototype
    main.c:1540: attention : passing argument 2 of «stringToTab" discards qualifiers from pointer target type
    main.c:1576: attention : passing argument 3 of «__builtin_strncpy" as unsigned due to prototype
    main.c:1588: attention : passing argument 3 of «__builtin_strncpy" as unsigned due to prototype
    main.c:1685: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c:1689: attention : format «%i" expects type «int", but argument 2 has type «struct Kase1Regl *"
    main.c:1690: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c:1696: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c:1699: attention : format «%i" expects type «int", but argument 2 has type «Kase1Regl_p"
    main.c:1728: attention : assignment from incompatible pointer type
    main.c:1737: attention : format «%i" expects type «int", but argument 2 has type «struct KaseLettr *"
    main.c:1740: attention : format «%i" expects type «int", but argument 2 has type «KaseLettre_p"
    main.c:1744: attention : format «%i" expects type «int", but argument 2 has type «struct Kasettr *"
    main.c:1752: attention : format «%i" expects type «int", but argument 2 has type «KaseLettre_p"
    main.c:1755: attention : format «%i" expects type «int", but argument 2 has type «KaseLettre_p"
    main.c:1761: attention : format «%i" expects type «int", but argument 2 has type «KaseLettre_p"
    main.c:1764: attention : format «%i" expects type «int", but argument 2 has type «KaseLettre_p"
    main.c:650: attention : unused variable «ligneChaine"
    main.c:639: attention : unused variable «uneCaseFitRule99"
    main.c:639: attention : unused variable «uneCaseFitRule2"
    main.c:639: attention : unused variable «uneCaseFitRuleFin"
    main.c:639: attention : unused variable «uneCaseFitRuleRetard"
    main.c:639: attention : unused variable «uneCaseFitRule"
    main.c:638: attention : unused variable «uneCaseLettre2"
    main.c:637: attention : unused variable «uneCase1Regl399"
    main.c:637: attention : unused variable «uneCase1Regl2"
    main.c:614: attention : unused variable «chnDim2"
    main.c:608: attention : unused variable «cpt3"
    main.c:608: attention : unused variable «v"
    main.c:608: attention : unused variable «poub"
    main.c:605: attention : unused variable «chn1"

  5. #5
    Membre émérite Avatar de nicolas.sitbon
    Profil pro
    Inscrit en
    Août 2007
    Messages
    2 015
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 2 015
    Points : 2 280
    Points
    2 280
    Par défaut
    J'ai corrigé rapidement ton code au moins pour pouvoir compiler, l'erreur de segmentation (du moins celle que tu stipules) se trouve dans ce bloc de code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    Kase1Regl_p ptr2FitRule;
                   /*  ptr2FitRule=(Kase1Regl_p) malloc (sizeof (Kase1Regl_t)); */
                   /*        ptr2FitRule->prec=NULL; */
                   /*        ptr2FitRule->suiv=NULL;  */
     
                   /*    while( !((cpt>5000  )|| ((nbFitRules(ptr2FitRule)==1) && (ptr2FitRule->rule->etat2=='qf')))) */
                   while (!
                          ((cpt > 5000)
                           || (((strcmp (ptr2FitRule->etat2, "qf")) == 0)
                               && ((ptr2FitRule->sortie2) = '!')
                               && ((ptr2FitRule->motionDir) == 'S'))))
    le problème étant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Kase1Regl_p ptr2FitRule;
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    strcmp (ptr2FitRule->etat2, "qf")
    ptr2FitRule n'est pas initialisé donc quand tu le déréférences ça plante.

Discussions similaires

  1. Modif html sur mon prog
    Par vins25 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 3
    Dernier message: 08/02/2006, 06h15
  2. GCC - Mon prog plante quand j'active -O1
    Par YéTeeh dans le forum Linux
    Réponses: 4
    Dernier message: 02/08/2005, 15h22
  3. Réponses: 2
    Dernier message: 06/06/2005, 15h13
  4. [C#] Créer un document à partir de mon prog
    Par matech dans le forum Windows Forms
    Réponses: 8
    Dernier message: 03/03/2005, 16h27
  5. Réponses: 11
    Dernier message: 28/02/2005, 13h23

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