Why is myfile.tellg() = 12 ?
tellg_pos.txt
1 2 3 4 5 6
|
1800567
Name1 Name2
72476
342424
text3 text5
|
1800567 has seven characters
then why is myfile.tellg() = 12 ?
My code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
int id;
ifstream myfile("tellg_pos.txt");
cout << "myfile.tellg()= " << myfile.tellg() << endl;
myfile >> id; //like as cin >> id
cout << "id= " << id << endl;
cout << "myfile.tellg()= " << myfile.tellg() << endl;
return 0;
}
|
myfile.tellg()= 0
id= 1800567
myfile.tellg()= 12 |
Did you write any spaces after 1800567?
No spaces. Just the numbers and then pressed Enter.
Topic archived. No new replies allowed.