Bonjour tout le monde,

Voila depuis peu je développe en C++ et je suis confronté à un problème que je n'arrive pas à comprendre... J'ai une classe Etudiants, en gros je range chaque étudiant crée dans un "vector" (donc de la librairie stl), j'ai ensuite une procédure censé écrire dans un fichier texte les informations relatives aux étudiants, sauf que le parcours ne se passe pas bien

_ Voici le code de la procédure :
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
17
void Ecriture_Fichier(){
 
   ofstream fichier("Reservation.txt",ios::out | ios::trunc);
  if(!fichier){
    cerr << "Erreur lors de l'ouverture du fichier reservation.txt" << endl;
  }
  else{
 
     for(int i=0;i<LesEtudiants.size();i++){
 
      fichier << LesEtudiants[i].numero() << " " <<  LesEtudiants[i].nom() << " " <<  LesEtudiants[i].prenom() << " " <<  LesEtudiants[i].annee() << " Etudiant " <<  LesEtudiants[i].mail() << " " <<  LesEtudiants[i].DateReservation() << " " <<  LesEtudiants[i].paye() << " et test" << endl; 
 
      }
    fichier.close();
    }
 
}

_ Voici l'erreur au moment de l'exécution :
*** glibc detected *** ./gala: free(): invalid pointer: 0xb7742ff4 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0x4ffff1]
/lib/tls/i686/cmov/libc.so.6[0x5016f2]
/lib/tls/i686/cmov/libc.so.6(cfree+0x6d)[0x5047cd]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xf316f1]
/usr/lib/libstdc++.so.6(_ZNSs4_Rep10_M_destroyERKSaIcE+0x1d)[0xf0f35d]
/usr/lib/libstdc++.so.6(_ZNSsD1Ev+0x4c)[0xf10d6c]
./gala[0x804b039]
./gala[0x804bee6]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x4abb56]
./gala[0x80493e1]
======= Memory map: ========
00110000-0012c000 r-xp 00000000 08:05 11973 /lib/libgcc_s.so.1
0012c000-0012d000 r--p 0001b000 08:05 11973 /lib/libgcc_s.so.1
0012d000-0012e000 rw-p 0001c000 08:05 11973 /lib/libgcc_s.so.1
00495000-005d3000 r-xp 00000000 08:05 9046 /lib/tls/i686/cmov/libc-2.10.1.so
005d3000-005d4000 ---p 0013e000 08:05 9046 /lib/tls/i686/cmov/libc-2.10.1.so
005d4000-005d6000 r--p 0013e000 08:05 9046 /lib/tls/i686/cmov/libc-2.10.1.so
005d6000-005d7000 rw-p 00140000 08:05 9046 /lib/tls/i686/cmov/libc-2.10.1.so
005d7000-005da000 rw-p 00000000 00:00 0
00667000-00668000 r-xp 00000000 00:00 0 [vdso]
0085d000-00878000 r-xp 00000000 08:05 16348 /lib/ld-2.10.1.so
00878000-00879000 r--p 0001a000 08:05 16348 /lib/ld-2.10.1.so
00879000-0087a000 rw-p 0001b000 08:05 16348 /lib/ld-2.10.1.so
008cf000-008f3000 r-xp 00000000 08:05 9050 /lib/tls/i686/cmov/libm-2.10.1.so
008f3000-008f4000 r--p 00023000 08:05 9050 /lib/tls/i686/cmov/libm-2.10.1.so
008f4000-008f5000 rw-p 00024000 08:05 9050 /lib/tls/i686/cmov/libm-2.10.1.so
00e79000-00f5f000 r-xp 00000000 08:05 10126 /usr/lib/libstdc++.so.6.0.13
00f5f000-00f63000 r--p 000e6000 08:05 10126 /usr/lib/libstdc++.so.6.0.13
00f63000-00f64000 rw-p 000ea000 08:05 10126 /usr/lib/libstdc++.so.6.0.13
00f64000-00f6b000 rw-p 00000000 00:00 0
08048000-08053000 r-xp 00000000 08:05 263510 /home/yves/Bureau/POO/gala
08053000-08054000 r--p 0000a000 08:05 263510 /home/yves/Bureau/POO/gala
08054000-08055000 rw-p 0000b000 08:05 263510 /home/yves/Bureau/POO/gala
090dc000-090fd000 rw-p 00000000 00:00 0 [heap]
b7600000-b7621000 rw-p 00000000 00:00 0
b7621000-b7700000 ---p 00000000 00:00 0
b772e000-b7730000 rw-p 00000000 00:00 0
b7742000-b7746000 rw-p 00000000 00:00 0
bff66000-bff7b000 rw-p 00000000 00:00 0 [stack]
22/4/2010Abandon
Merci d'avance.

EDIT : Même erreur avec un iterator :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
vector <Etudiant>::iterator ie;
vector <Etudiant> LesEtudiants;
/*
....
*/
for(ie=LesEtudiants.begin();ie<LesEtudiants.end();ie++){
 
      fichier << ie->numero() << " " <<  ie->nom() << " " <<  ie->prenom() << " " <<  ie->annee() << " Etudiant " <<  ie->mail() << " " <<  ie->DateReservation() << " " <<  ie->paye() << " et test" << endl; 
 
      }