read.cpp
#include <iostream>
#include <fstream>
using namespace std;
int main(void)
{
int id;
char name[50];
ifstream myfile("savingaccount.txt"); //open the file
myfile >> id;
cout << myfile.tellg(); //return 16? but not 7 or 8
cout << id ;
return 0;
}
Savingaccount.txt
1800567 Ho Rui Jang 21 女性 マレーシア人 012-4998192 20、Lorong 13、Taman Patani Janam マラッカ Sungai Dulong
問題
がtellg()
返される7
か8
、最初の行1800567
が7桁であるため、ストリームポインタはこの数値の後、文字列の前に配置する必要があります"Ho Rui Jang"
が、をtellg()
返します16
。なんでそうなの?