modification non voulue de variable
Bonjour,
Voila, j'ai une variable "nomsdesobjets" qui est de type char*. Elle est définie correctement en début du programme par une procédure :
appel :
Code:
objetsetattributs(fichM, &nomsdesobjets,&nomsdesattributs, dernierephrase);
procedure :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| void objetsetattributs(FILE*fichM, char** nomsdesobjets,char** nomsdesattributs, char* dernierephrase)
{
char chaineTMP [Nmcl];
char chaine1 [Nmcl];
char CHAINE2 [Nmcl];
int iemecaractereligne=0;
int c;
rewind(fichM);
fgets(chaineTMP, sizeof chaineTMP, fichM);
while(strcmp(chaineTMP,dernierephrase)) // tant que l'on est pas la ligne "Name_of_dataset"
{
fgets(chaineTMP, sizeof chaineTMP, fichM);
}
fgets(CHAINE2, sizeof CHAINE2, fichM);
fgets(chaine1, sizeof chaine1, fichM);
*nomsdesattributs=chaine1;
*nomsdesobjets=CHAINE2;
} |
Cette variable "nomsdesobjets" reste correctement définie jusqu'au moment ou je fais appel a une procédure "groupeetchoixgen" qui ne fait pas appel a la variable "nomsdesobjets". Mais après cette procédure, ma variable "nomsdesobjets" a quand même changé. Elle a pour valeur l'autre variable de type char* "nomsdesgroupes" qui est en parametre de la procedure "groupeetchoixgen" :
appel :
Code:
groupeetchoixgen(fichGA, &choixGEN, &alpha,&nomsdesgroupes);
procedure :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| void groupeetchoixgen(FILE* fichG, int*choixGEN, double* alpha, char** nomsdesgroupes)
{
int c,iemecaractereligne=0, numerocaractere=0,numeromot=0;
char CHTMP [Nmcl];
double d;
fscanf(fichG, "%d",choixGEN); //recuperation de la methode de generalisation voulue
printf("choixGEN : %d\n", *choixGEN);
if(*choixGEN==1)
{
fscanf(fichG, "%lf",&d);
*alpha=d;
printf("alpha : %lf\n", *alpha);
}
fgets(CHTMP, sizeof CHTMP, fichG);//recupere le reste de la ligne
fgets(CHTMP, sizeof CHTMP, fichG);
*nomsdesgroupes=CHTMP;
} |
Voyez vous pourquoi ?
N'existe t' il pas un moyen de bloquer cette modification ?