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 :

erreurs dans la compilation


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 15
    Par défaut erreurs dans la compilation
    Bonjour
    Je suis débutant en langage C et j'ai essayé d'écrire un programme , mais lors de la compilation il m'affiche plein d'erreurs .
    le voilà le code si quelqu'un peut m'aider un peu et merci infiniment .

    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
    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
     
    typedef struct pere
    {
    	char pere[6];
    	char datepere[8];
    	struct enfant_t *enfant;
    	struct pere_t *suiv;
    }pere_t;
     
     
    typedef struct enfant
    {
    	char enfant[6];
    	char dateenfant[8];
    	struct enfant_t *suiv;
    }enfant_t;
     
    pere_t **  insertion_pere (pere_t ** prec, pere_t nouv)
    {	
    	nouv->suivant = * prec ;
    	* prec = nouv;
    	prec = &(nouv->suivant);
    	return prec;
    }
     
    enfant_t ** insertion_enfant (enfant_t ** prec, enfant_t nouv)
    {
    	nouv->suivant = * prec ;
    	* prec = nouv;
    	prec = &(nouv->suivant);
    	return prec;
    }
     
    pere_t* creation_pere (char *pere,char *datepere)
    {
      nouv=(pere_t *)malloc(sizeof(pere_t));
      strncpy(nouv->pere,pere,6);
      strncpy(nouv->datepere,datepere,8);
      nouv->enfant=NULL;
      nouv->suivant=NULL;
      return nouv;
    }
     
    enfant_t* creation_enfant (char *enfant,char *dateenfant)
    {
      nouv=(enfant_t *)malloc(sizeof(enfant_t));
      strncpy(nouv->enfant,enfant,6);
      strncpy(nouv->dateenfant,dateenfant,8);
      nouv->suivant=NULL;
      return nouv;
    }
     
    pere_t * recherche_pere (char *identifiantpere,pere_t **tete)
    {
    		pere_t **prec=tete;
    	   pere_t *cour = *prec;
    		while ((cour != NULL)&& (strncpy(cour->pere,identifiantpere,6)!=0))
    		{
    			cour = cour->suiv;
    		}
    		return prec;
    }
     
    enfant_t * recherche_enfant (char *identifiantpere,char *identifiantenfant,pere_t **tete)
    {
       prec = recherche_pere(identifiantpere,tete);
       enfant_t *cour =*(prec->enfant);
       if (prec != NULL )
       	{
       		while ((cour != NULL) && (strncpy(cour->enfant,identifiantenfant,6)!=0)
       			{
       				cour = cour->suiv;
    			}
    			return cour;
    	}
    }
     
    void suppression_pere (char *identifiantpere,pere_t **tete)
    {
    		pere_t **prec=tete;
    	    pere_t *cour = *prec;
    		while ((cour != NULL)&& (strncpy(cour->pere,identifiantpere,6)!=0))
    		{
    			prec = &(cour->suiv);
    			cour = *prec;
    		}
    		if (cour != NULL)
    			{
    				*prec = (cour->suiv);
    			}
    }
     
    void suppression_enfant (char *identifiantpere,char *identifiantenfant,pere_t **tete)
    {
       prec = recherche_pere(identifiantpere,tete);
       enfant_t *cour =*(prec->enfant);
       enfant_t **prec1 = (prec->enfant);
       if (prec != NULL )
       	{
       		while ((cour != NULL) && (strncpy(cour->enfant,identifiantenfant,6)!=0)
       			{	
    				prec1 = &(cour->suiv);
    			    cour = *prec1;
    			}
    			if (cour != NULL )
    				{
    					*prec1 = (cour->suiv);
    				}
    	}
    }
     
    void main(int argc , char ** argv)
    {
    	int i ;
    	char enfant[6];
    	char pere[6];
    	char datepere[8];
    	char dateenfant[8];
    	int nombre[2];
    	pere_t *nouveau_pere;
    	enfant_t *nouveau_enfant; 
    	pere_t * tete = NULL;
    	pere_t  ** precP=&tete;
    	enfant_t ** precF;
    	FILE * fichier = fopen (argv[1],"r");
    	if (fichier)
    		{
    		while (! feop(fichier))
    		fscanf (fichier,"%6c%8c%2d",&pere,&datepere,&nombre);
    		fprintf ("%.6s%.8s%.2d",pere,datepere,nombre);
    		nouveau_pere=creation_pere(pere,datepere);
    		precP=insertion_pere (precP,nouveau_pere);
    		precF=&(pere->enfant);
    			for ( i=0;i<*nombre;i++)
    			{
    			fscanf (fichier,"%6c%8c",&enfant,&dateenfant);
    			fprintf ("%.6s%.8s",enfant,dateenfant);
    			nouveau_enfant=creation_enfant(enfant,dateenfant);
    			precF=insertion_enfant (precF,nouveau_enfant);
    			}
    		fscanf (fichier,"%c");
    		}
    			fclose(fichier);
    }

  2. #2
    Expert confirmé
    Avatar de Thierry Chappuis
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Mai 2005
    Messages
    3 499
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Suisse

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : Mai 2005
    Messages : 3 499
    Par défaut
    Quels messages d'erreurs obtiens-tu? Moi, j'ai ça:

    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
    ||=== dvp, Debug ===|
    /home/thierry/devel/forums/dvp/main.c||In function «insertion_pere":|
    /home/thierry/devel/forums/dvp/main.c|23|erreur: invalid type argument of «->"|
    /home/thierry/devel/forums/dvp/main.c|24|erreur: incompatible types in assignment|
    /home/thierry/devel/forums/dvp/main.c|25|erreur: invalid type argument of «->"|
    /home/thierry/devel/forums/dvp/main.c||In function «insertion_enfant":|
    /home/thierry/devel/forums/dvp/main.c|31|erreur: invalid type argument of «->"|
    /home/thierry/devel/forums/dvp/main.c|32|erreur: incompatible types in assignment|
    /home/thierry/devel/forums/dvp/main.c|33|erreur: invalid type argument of «->"|
    /home/thierry/devel/forums/dvp/main.c||In function «creation_pere":|
    /home/thierry/devel/forums/dvp/main.c|39|erreur: «nouv" undeclared (first use in this function)|
    /home/thierry/devel/forums/dvp/main.c|39|erreur: (Each undeclared identifier is reported only once|
    /home/thierry/devel/forums/dvp/main.c|39|erreur: for each function it appears in.)|
    /home/thierry/devel/forums/dvp/main.c|45|attention : control reaches end of non-void function|
    /home/thierry/devel/forums/dvp/main.c||In function «creation_enfant":|
    /home/thierry/devel/forums/dvp/main.c|49|erreur: «nouv" undeclared (first use in this function)|
    /home/thierry/devel/forums/dvp/main.c|54|attention : control reaches end of non-void function|
    /home/thierry/devel/forums/dvp/main.c||In function «recherche_pere":|
    /home/thierry/devel/forums/dvp/main.c|62|attention : assignment from incompatible pointer type|
    /home/thierry/devel/forums/dvp/main.c|64|attention : return from incompatible pointer type|
    /home/thierry/devel/forums/dvp/main.c||In function «recherche_enfant":|
    /home/thierry/devel/forums/dvp/main.c|69|erreur: «prec" undeclared (first use in this function)|
    /home/thierry/devel/forums/dvp/main.c|70|attention : ISO C90 forbids mixed declarations and code|
    /home/thierry/devel/forums/dvp/main.c|74|erreur: expected «)" before «{" token|
    /home/thierry/devel/forums/dvp/main.c|78|erreur: expected expression before «}" token|
    /home/thierry/devel/forums/dvp/main.c|79|attention : control reaches end of non-void function|
    /home/thierry/devel/forums/dvp/main.c||In function «suppression_pere":|
    /home/thierry/devel/forums/dvp/main.c|87|attention : assignment from incompatible pointer type|
    /home/thierry/devel/forums/dvp/main.c|92|attention : assignment from incompatible pointer type|
    /home/thierry/devel/forums/dvp/main.c||In function «suppression_enfant":|
    /home/thierry/devel/forums/dvp/main.c|98|erreur: «prec" undeclared (first use in this function)|
    /home/thierry/devel/forums/dvp/main.c|99|attention : ISO C90 forbids mixed declarations and code|
    /home/thierry/devel/forums/dvp/main.c|104|erreur: expected «)" before «{" token|
    /home/thierry/devel/forums/dvp/main.c|112|erreur: expected expression before «}" token|
    /home/thierry/devel/forums/dvp/main.c|100|attention : unused variable «prec1"|
    /home/thierry/devel/forums/dvp/main.c|116|attention : return type of «main" is not «int"|
    /home/thierry/devel/forums/dvp/main.c||In function «main":|
    /home/thierry/devel/forums/dvp/main.c|131|attention : implicit declaration of function «feop"|
    /home/thierry/devel/forums/dvp/main.c|132|attention : format «%6c" expects type «char *", but argument 3 has type «char (*)[6]"|
    /home/thierry/devel/forums/dvp/main.c|132|attention : format «%8c" expects type «char *", but argument 4 has type «char (*)[8]"|
    /home/thierry/devel/forums/dvp/main.c|132|attention : format «%2d" expects type «int *", but argument 5 has type «int (*)[2]"|
    /home/thierry/devel/forums/dvp/main.c|133|attention : passing argument 1 of «fprintf" from incompatible pointer type|
    /home/thierry/devel/forums/dvp/main.c|135|erreur: incompatible type for argument 2 of «insertion_pere"|
    /home/thierry/devel/forums/dvp/main.c|136|erreur: request for member «enfant" in something not a structure or union|
    /home/thierry/devel/forums/dvp/main.c|139|attention : format «%6c" expects type «char *", but argument 3 has type «char (*)[6]"|
    /home/thierry/devel/forums/dvp/main.c|139|attention : format «%8c" expects type «char *", but argument 4 has type «char (*)[8]"|
    /home/thierry/devel/forums/dvp/main.c|140|attention : passing argument 1 of «fprintf" from incompatible pointer type|
    /home/thierry/devel/forums/dvp/main.c|142|erreur: incompatible type for argument 2 of «insertion_enfant"|
    /home/thierry/devel/forums/dvp/main.c|144|attention : trop peu d'arguments dans le format|
    /home/thierry/devel/forums/dvp/main.c|115|attention : unused parameter «argc"|
    ||=== Build finished: 40 errors, 0 warnings ===|
    En vrac et de manière non exhaustive:
    • Dans les fonctions insertion_pere() et insertion_enfant(), le paramètre nouv n'est pas un pointeur. Or, la première ligne de ces deux fonctions fait appel à nouv->suivant qui, je le rappelle est équivalent à (*nouv).suivant.
    • Dans nouv insertion_pere() est de type pere_t tandis que *prec est de type pointeur sur pere_t.
    • Dans nouv insertion_enfant() est de type enfant_t tandis que *prec est de type pointeur sur enfant_t.
    • Dans creation_pere(), la variable nouv n'a pas été définie.
    • En C il est déconseillé de caster la valeur retournée par malloc().
    • Par contre, il est fortement conseillé de toujours vérifier que la valeur retournée par malloc() n'est pas égale à NULL.
    • Dans recherche_enfant(), la variable prec n'a pas été définie.
    • Dans recherche_enfant(), tu définis des variables ailleurs qu'au début d'un bloc, ce qui n'est pas autorisé en C90.
    • main() retourne un entier de type int, TOUJOURS!
    • Les trois valeurs portables que peut retourner main() sont 0, EXIT_SUCCESS et EXIT_FAILURE.
    • etc.


    Thierry
    "The most important thing in the kitchen is the waste paper basket and it needs to be centrally located.", Donald Knuth
    "If the only tool you have is a hammer, every problem looks like a nail.", probably Abraham Maslow

    FAQ-Python FAQ-C FAQ-C++

    +

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 15
    Par défaut merci infiniment
    Salut Thierry , je vous remercie bcp pour votre réponse , mais en tant que débutant j'arrive pas a comprendre la totalité de vos conseils , veuillez svp m'expliquer comment je pourrais corriger mes erreurs lors de la compilation .
    et merci une deuxième fois .

  4. #4
    Expert confirmé
    Avatar de Thierry Chappuis
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Mai 2005
    Messages
    3 499
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Suisse

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Industrie Pharmaceutique

    Informations forums :
    Inscription : Mai 2005
    Messages : 3 499
    Par défaut
    Serait-il possible d'avoir un exemple de fichier que tu passes en argument de ton programme?

    Thierry
    "The most important thing in the kitchen is the waste paper basket and it needs to be centrally located.", Donald Knuth
    "If the only tool you have is a hammer, every problem looks like a nail.", probably Abraham Maslow

    FAQ-Python FAQ-C FAQ-C++

    +

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 15
    Par défaut le fichier
    Bonjour
    Mon fichier est nommé : fichier , et contient les lignes suivantes :

    papa011960050502fils0119800320fils0219810202
    papa021960050500
    papa031960050500



    Merci pour votre aide
    a bientot

Discussions similaires

  1. des erreurs dans la compilation(la bibliothèque IPL98)
    Par hanou88 dans le forum C++Builder
    Réponses: 2
    Dernier message: 28/05/2011, 18h46
  2. Directshow & Visual Studio 8 : erreur dans la compilation
    Par L'elfe d'Azur dans le forum Windows
    Réponses: 5
    Dernier message: 03/10/2007, 13h21
  3. Erreur dans la compilation à résoudre
    Par nadjib2007 dans le forum C++
    Réponses: 5
    Dernier message: 29/07/2007, 00h03
  4. Erreur dans la Compilation ?
    Par Sceener dans le forum C++
    Réponses: 6
    Dernier message: 05/07/2007, 10h54
  5. [mono] Compilation sous linux, erreur dans windows
    Par AlexandreP dans le forum Mono
    Réponses: 6
    Dernier message: 18/08/2006, 19h56

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