[問題] tellg會吃資料(dev c++)
最近使用tellg, seekg出現了問題
寫了一個測試的檔案
先設立test.txt裡面存
1234567890 9876543210
1234567890 9876543210
1234567890 9876543210
然後test.cpp中寫
ifstream test("test.txt");
string e;
test >> e;
cout << e << ' ' << test.tellg() << endl;
test >> e;
cout << e << ' ' << test.tellg() << endl;
test >> e;
cout << e << ' ' << test.tellg() << endl;
system("pause");
test.close();
結果出來是
1234567890 12
876543210 23
1234567890 34
中間的9不見了
請問這是甚麼原因呢?
謝謝各位
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.97.87
推
04/05 17:26, , 1F
04/05 17:26, 1F
→
04/05 17:32, , 2F
04/05 17:32, 2F
推
04/05 17:40, , 3F
04/05 17:40, 3F
→
04/05 17:41, , 4F
04/05 17:41, 4F
→
04/05 17:43, , 5F
04/05 17:43, 5F
→
04/05 17:43, , 6F
04/05 17:43, 6F
推
04/05 17:51, , 7F
04/05 17:51, 7F
→
04/05 17:51, , 8F
04/05 17:51, 8F
→
04/05 18:38, , 9F
04/05 18:38, 9F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):