假設現在我有一檔案如下(example.txt)zzz, xxx, yyy, ttt,aaa, bbb, ccc, ddd,eee, fff, ggg, hhh,假設我我現在程式讀到了 ccc, 並輸出到螢幕上我現在想要跳回去讀 aaa, 並輸出到螢幕上請問各位高手,要如何將檔案的當前讀取的位子往前移感謝萬分~附上我讀取檔案用的語法,在4摟
詩人1234 wrote:可以問一下你是用哪種...(恕刪) 這是我用的語法char* FileNameIn="StudentScore.txt";char* target = new char [20];ifstream FileInput;FileInput.open(FileNameIn);...FileInput >> target;cout << target << endl ;抱歉我是C++新手
lichcen wrote:這是我用的語法cha...(恕刪) ifstream::seekg (inherited from istream)。google 一下吧。應該是FileInput.seekg(0, ios::beg)
bazinewbie wrote:ifstream::...(恕刪) 我GOOGLE很久了我FileInput.seekg(0, ios::beg)後再將它COUT輸出結果還是停在ccc我只會用FileInput >> target;FileInput >> target;數次這樣往前推進,到想要的位子時後再cout << target ;現在我想要回到前幾個字串再把它輸出有類似的方式嗎又seekg還要算要退幾個字元?好像很不好做感謝回覆~