我在覆蓋C++文件中的某些數據時遇到問題。單讀音使用的代碼是C++覆蓋特定位置的文件中的數據
int main(){
fstream fout;
fout.open("hello.txt",fstream::binary | fstream::out | fstream::app);
pos=fout.tellp();
fout.seekp(pos+5);
fout.write("####",4);
fout.close();
return 0;
}
問題即使使用seekp之後,數據總是寫入在end.I希望將其在特定位置寫。 如果我不添加fstream ::應用程序,該文件的內容被刪除。 謝謝。
你想覆蓋的數據的確切位置是什麼? – Flinsch