ofstream outfile; outfile.open("file.dat", ios::out | ios::trunc );類似地,您如果想要打開一個文件用于讀寫,可以使用下面的語法:fstream afile; afile.open("file.dat", ios::out | ios::in );關(guān)閉文件當C++ 程序終止時,它會自動關(guān)閉刷新所有流,釋放所有分配的內(nèi)存,并關(guān)閉所有打開的文件。但程序員...
edu.jb51.net/cplusplus/cplusplus-fil... 2025-5-19