S
Son of Sam
Hi, I just want to open a file, let it replace 1 string (which occurs a
few times) and write it to the same file, it must be binary.
I tryed following code but it doesnt work as I thought:
#include <iostream>
#include <fstream>
#include <string>
#include <tchar.h>
#include <stdio.h>
#include <time.h>
#include <ctime>
#include <cstdlib>
#include <sstream>
#include <vector>
using namespace std;
fstream f;
string contents;
string oldbinstring = "1234567";
string newbinstring = "a610f82";
string mybinfile = "boom.bin";
f.open(mybinfile, "rb");
contents = f.read();
contents.replace(oldbinstring, newbinstring);
f.close();
f.open(mybinfile, "wb");
f.write(contents);
f.close();
Thanks for any help
Sam
few times) and write it to the same file, it must be binary.
I tryed following code but it doesnt work as I thought:
#include <iostream>
#include <fstream>
#include <string>
#include <tchar.h>
#include <stdio.h>
#include <time.h>
#include <ctime>
#include <cstdlib>
#include <sstream>
#include <vector>
using namespace std;
fstream f;
string contents;
string oldbinstring = "1234567";
string newbinstring = "a610f82";
string mybinfile = "boom.bin";
f.open(mybinfile, "rb");
contents = f.read();
contents.replace(oldbinstring, newbinstring);
f.close();
f.open(mybinfile, "wb");
f.write(contents);
f.close();
Thanks for any help
Sam