Sorry for the triple post, but I figured it out so I thought I should post my findings for future reference. It seems weird but this works:
ofstream File;
File.open("file .txt", ios::in); //notice the ios::in, this is what made it work
File.seekp(8, ios::beg);
File << "four";
File.close();
User Profile
Collapse
-
*bump* Theres really no way to do this? Is my only option to convert the whole file to binary?Leave a comment:
-
when I change File << "four"; to File.write("fou r", 8); all that shows up in the file is "four" eight characters from the start of the file, everything else is goneLeave a comment:
-
Can you use seekp without ios::binary?
My actual problem is much larger but figuring out how to do this example will help me. I want to overwrite data that already exists in a text file but I can't seem to do this.
ex.
[file.txt]
I have five fingers.
My current code:
...Code:ofstream File; File.open("file.txt", ios::out); File.seekp(8, ios::beg); File << "four"; File.close();
No activity results to display
Show More
Leave a comment: