This is my code (without error checking):
std::wfstream wfs("C:\\testfile.txt");
wfs.setf(std::ios_base::binary);
std::wstringstream wss;
wss << wfs.rdbuf();
wfs.seekp(0);
wfs << L"new";
Now, the first three characters in the file are replaced with "new". However, I would like "new" to be the only contents of the file.
How do I achieve that?