[問題] tellg會吃資料(dev c++)
看板C_and_CPP (C/C++)作者htymrednuht (htymrednuht)時間16年前 (2010/04/05 16:37)推噓3(3推 0噓 6→)留言9則, 2人參與討論串1/2 (看更多)
最近使用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 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章