檔案流物件的重用, 必須用infile.close() infile.clear()
阿新 • • 發佈:2019-02-11
輸出結果:// 輸出結果不容易理解,以後得學會除錯輸出
the content of the first file :
thefirstfileopensuccessfully.
the content of the second file :
infile.eof() is true. 說明infile檔案流物件在讀完first file後必須用clear清空狀態
,否則infile.eof()狀態一直是true
不去檢查eof()而直接輸出,the fisrt string of the second file is:
the content of the second file : thesecondfileopensuccessfully!
Press any key to continue
應該如此輸出:;
Mode Meaning
ios::app append output
ios::ate seek to EOF when opened
ios::binary open the file in binary mode
ios::in open the file for reading
ios::out open the file for writing
ios::trunc overwrite the existing file