vendredi 3 janvier 2020

why the function tellg() does not return the good result?

I don't understand why my function tellg() jumps from 0 to 2 here is my code:

ifstream uploadFile("upload.txt");
 char letter;
    uploadFile.seekg(0);
    cout<<uploadFile.tellg()<<endl;
    while(uploadFile.get(letter))
        cout<<uploadFile.tellg()<<endl;
    return 0;

My file contains this line:

0 TS1

These are the results I expect:

0
1
2
3
4
5
6

but I get this:

0
2
3
4
5
6
7

Aucun commentaire:

Enregistrer un commentaire