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 :

Erreur d'initialisation à la compilation


Sujet :

C

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2011
    Messages : 13
    Points : 9
    Points
    9
    Par défaut Erreur d'initialisation à la compilation
    Bonjour à tous !

    Après être passé sur le chat IRC on m'a conseillé de poster mon problème ici :

    J'ai une erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Run-Time Check Failure #3 - The variable 'GrapheCharge' is being used without being initialized.
    sur ce 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
    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
    #include <stdio.h>
    #include <stdlib.h>
     
     
    //Structure du graphe
    struct Graphe{
    	int matadj[9][9];
    	char listeadj[9][9];
    	char nomsom[9];
    	int nbrsom;
    	int orient;
    };
     
     
    //Initialisation de toutes les fonctions
    void InitGraph(Graphe GrapheCharge);
    void MatriceAdj(char *matadj1,char *matadj2,Graphe GrapheCharge);
    void ChargerGraphe(char chemin[],Graphe GrapheCharge);
    void ListeAdj(char *matadj1,char *matadj2,Graphe GrapheCharge);
    void Connexe(Graphe GrapheCharge);
    void FortementConnexe();
     
     
    //Initialisation du graphe
    void InitGraph(Graphe GrapheCharge){
    	int l,c;
    	for(l=0;l<10;l++){
    		GrapheCharge.nomsom[l]=0;
    	}
    	GrapheCharge.nbrsom = 0;
    	GrapheCharge.orient = 0;
    	for(l=0;l<10;l++){
    		for(c=0;c<10;c++){
    			GrapheCharge.listeadj[l][c]=0;
    			GrapheCharge.matadj[l][c]=0;
    		}
    	}
    }
     
    //Cette fonction charge un graphe à partir d'un fichier texte
    void ChargerGraphe(char chemin[],Graphe GrapheCharge){
     
    	//Chargement du fichier et initialisation du graphe
     
    	FILE *pFile;
    	char ligne_lue[20];
    	int ligne;
    	ligne = 0;
    	int i,l,c;
    	char matadj1,matadj2;
    	pFile = fopen("chemin","r");
     
    	//Lecture du fichier, inscription des informations du graphe dans GrapheCharge.
     
    	if(pFile!=NULL){
     
    		while(fgets(ligne_lue, 500, pFile) != NULL){
    			if(ligne==0){
    				fscanf(pFile,"Orientation : %d",GrapheCharge.orient);
    			}
     
    			if(ligne==1 && GrapheCharge.orient==0){
    				fscanf(pFile, "%c %c %c %c %c %c %c %c %c %c", GrapheCharge.nomsom[0],GrapheCharge.nomsom[1],GrapheCharge.nomsom[2],GrapheCharge.nomsom[3],GrapheCharge.nomsom[4],GrapheCharge.nomsom[5],GrapheCharge.nomsom[6],GrapheCharge.nomsom[7],GrapheCharge.nomsom[8],GrapheCharge.nomsom[9]);
    				for(i=0;i<10;i++){
    					if(GrapheCharge.nomsom[i]!=0){
    						GrapheCharge.nbrsom++;
    					}
    				}
    				ligne++;
    			}
    			 //Après avoir déterminé si le graphe est orienté (1) ou non (0) ainsi que le nom et nombre de sommets, on lance les autres fonction pour determiner matrice et liste d'adjacence.
     
    			if(GrapheCharge.orient==0 && ligne!=0 && ligne!=1){
    				fscanf(pFile, "%c %c",matadj1,matadj2);
    				MatriceAdj(&matadj1,&matadj2,GrapheCharge);
    			}
    		}
    	}else{
          printf("Impossible d'ouvrir le fichier %s\n", chemin);
          exit(1);
      }
    }
     
     
    //Cette fonction génère la matrice d'adjacence.
    void MatriceAdj(char *matadj1,char *matadj2,Graphe GrapheCharge){
    	int l,c;
    	if(matadj1=="A"){l = 0;}
    	if(matadj1=="B"){l = 1;}
    	if(matadj1=="C"){l = 2;}
    	if(matadj1=="D"){l = 3;}
    	if(matadj1=="E"){l = 4;}
    	if(matadj1=="F"){l = 5;}
    	if(matadj1=="G"){l = 6;}
    	if(matadj1=="H"){l = 7;}
    	if(matadj1=="I"){l = 8;}
    	if(matadj1=="J"){l = 9;}
    	if(matadj2=="A"){c = 0;}
    	if(matadj2=="B"){c = 1;}
    	if(matadj2=="C"){c = 2;}
    	if(matadj2=="D"){c = 3;}
    	if(matadj2=="E"){c = 4;}
    	if(matadj2=="F"){c = 5;}
    	if(matadj2=="G"){c = 6;}
    	if(matadj2=="H"){c = 7;}
    	if(matadj2=="I"){c = 8;}
    	if(matadj2=="J"){c = 9;}
    	if(GrapheCharge.orient=0){
    		GrapheCharge.matadj[l][c]=1;
    		GrapheCharge.matadj[c][l]=1;
    	}else{
    		GrapheCharge.matadj[l][c]=1;
    	}
    }
     
    void ListeAdj(char *matadj1,char *matadj2,Graphe GrapheCharge){
    	int l,c;
    	if(matadj1=="A"){l = 0;}
    	if(matadj1=="B"){l = 1;}
    	if(matadj1=="C"){l = 2;}
    	if(matadj1=="D"){l = 3;}
    	if(matadj1=="E"){l = 4;}
    	if(matadj1=="F"){l = 5;}
    	if(matadj1=="G"){l = 6;}
    	if(matadj1=="H"){l = 7;}
    	if(matadj1=="I"){l = 8;}
    	if(matadj1=="J"){l = 9;}
    	while(GrapheCharge.listeadj[l][c]!=0){
    		c++;
    	}
    	GrapheCharge.listeadj[l][c]=*matadj2;
    }
     
    //Cette fonction détermine si le graphe est connexe
     
    void Connexe(Graphe GrapheCharge){
    	int l,c;
    }
     
     
    //Initialisation du programme
    int main(int argc, char *argv[]){
    	Graphe GrapheCharge;
    	char chemin[50];
    	printf("Bienvenue dans l'algorithme de manipulation des graphes.\nVeuillez entrer un chemin de fichier texte (Absolu) : ");
    	scanf ("%s",&chemin);
    	InitGraph(GrapheCharge);
    	ChargerGraphe(chemin,GrapheCharge);
    	return 0;
    }
    Qui apparait à la compilation.
    Au debug, ce sont les lignes InitGraphe(GrapheCharge); et la suivante qui provoquent l'affichage de cette erreur.

    Je travaille sur Visual Studio 2010 et celui-ci ne m'affiche aucune erreur / warning avant la compilation.

    Merci d'avance o/

    - Brut4 -

  2. #2
    Inactif  


    Homme Profil pro
    Doctorant sécurité informatique — Diplômé master Droit/Économie/Gestion
    Inscrit en
    Décembre 2011
    Messages
    9 012
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 31
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Doctorant sécurité informatique — Diplômé master Droit/Économie/Gestion
    Secteur : Enseignement

    Informations forums :
    Inscription : Décembre 2011
    Messages : 9 012
    Points : 23 145
    Points
    23 145
    Par défaut
    Si tu veux modifier ton graphe à l'intérieur d'un fonction deux solutions :

    - Ta fonction dois retourner un graphe et tu dois faire une affectation
    - Tu envois un pointeur sur graphe à ta fonction.

  3. #3
    Rédacteur/Modérateur


    Homme Profil pro
    Network game programmer
    Inscrit en
    Juin 2010
    Messages
    7 116
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : Canada

    Informations professionnelles :
    Activité : Network game programmer

    Informations forums :
    Inscription : Juin 2010
    Messages : 7 116
    Points : 32 969
    Points
    32 969
    Billets dans le blog
    4
    Par défaut
    En C tous les paramètres sont passés par copie.
    Toutes tes fonctions ont des copies de Graphe, ce qui implique que leur modification n'est effective qu'à l'intérieur de la fonction, mais le Graphe original passé en paramètre ne subit aucune modification.
    Pour modifier un paramètre, il faut passer un pointeur avec l'adresse du Graphe.
    Pensez à consulter la FAQ ou les cours et tutoriels de la section C++.
    Un peu de programmation réseau ?
    Aucune aide via MP ne sera dispensée. Merci d'utiliser les forums prévus à cet effet.

  4. #4
    Futur Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Août 2011
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2011
    Messages : 13
    Points : 9
    Points
    9
    Par défaut
    Merci beaucoup !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Erreur avec Glibc en compilation croisée
    Par Senaku-seishin dans le forum Linux
    Réponses: 2
    Dernier message: 02/12/2005, 14h12
  2. Erreur d'initialisation de requête - option RTF
    Par verticka dans le forum WinDev
    Réponses: 2
    Dernier message: 25/11/2005, 09h55
  3. [BDE Errors] Erreur d'initialisation
    Par SubZero2 dans le forum Bases de données
    Réponses: 2
    Dernier message: 13/07/2005, 08h46
  4. Erreur d'initialisation du BDE sous Delphi7 ent et WinXP
    Par touhami dans le forum Bases de données
    Réponses: 1
    Dernier message: 15/02/2005, 01h51
  5. [Tomcat MySQL] Erreur d'initialisation d'un pool
    Par mmed dans le forum Eclipse Java
    Réponses: 2
    Dernier message: 05/01/2005, 09h22

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