Bonjour,
Voila j'ai un énorme (enfin tou tdu moins déroutant) problème sur un truc aussi idiot que la lecture d'un fichier
Le fichier "essai" que je veux lire contient 10 fois cette même ligne :
"abcdefghijklmnopqrstuvwxyz"
sortie console :
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 #include <iostream> #include <fstream> using namespace std; int main () { ifstream inVF("essai", ios::in); inVF.seekg(0, ios::beg ); long position = 0; while(!inVF.eof()) { string chaineVF; position = inVF.tellg(); getline(inVF, chaineVF); cout<<"## chaineVF : "<<chaineVF<<endl; cout<<"## position : "<<position<<endl; } inVF.close(); return 0; }
Je soupconne trés fortement le tellg qui vient tout foutre en l'air, car quand je ne l'utilise pas tout ce passe bien, et franchement je vois pas pourquoi l'utilisation de tellg viendrait autant perturbé le getline, je suis perdu ...
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 ## chaineVF : abcdefghijklmnopqrstuvwxyz ## position : 0 ## chaineVF : ijklmnopqrstuvwxyz ## position : 36 ## chaineVF : hijklmnopqrstuvwxyz ## position : 63 ## chaineVF : ghijklmnopqrstuvwxyz ## position : 90 ## chaineVF : fghijklmnopqrstuvwxyz ## position : 117 ## chaineVF : efghijklmnopqrstuvwxyz ## position : 144 ## chaineVF : defghijklmnopqrstuvwxyz ## position : 171 ## chaineVF : cdefghijklmnopqrstuvwxyz ## position : 198 ## chaineVF : bcdefghijklmnopqrstuvwxyz ## position : 225 ## chaineVF : abcdefghijklmnopqrstuvwxyz ## position : 252
Alors si quelqu'un peut m'expliquer clairement d'où vient le problème ca serait sympa, merci
Partager