Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ edit a binary file with another
    primarykey
    data
    text
    <p>Solved! thanks all of you very much. My day has been made!(well morning, its 4am)</p> <p>I'm trying to write a program in C++ that opens a .dat file in binary and replaces the first 1840 hex characters with that of another .dat file, while leaving the remaining hex values of the first .dat file the same. I have spent about 12 hours on this today and have had little success. I am a beginner programmer, I have taken one semester worth of c++ courses and we did not get to streams. </p> <p>(it opens a file and everything, but deletes every thing after the new values have been added)</p> <pre><code>#include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;fstream&gt; #include &lt;string&gt; #include &lt;cmath&gt; #include &lt;cstring&gt; using namespace std; int main (){ string filename; long size; char* memblock; cout &lt;&lt; " Enter a file to be modded by Mod.dat "; cin &gt;&gt; filename; ofstream infile ( filename ,std::ofstream::binary); //filename: the file that will be opened and changed) ifstream modFile ("Mod.dat", ifstream::binary); // (mod.dat is the file that i get the first 1840 hex values from) modFile.seekg (0,modFile.end); size = modFile.tellg(); memblock = new char [size]; modFile.seekg (0, ios::beg); modFile.read (memblock, size); infile.write(memblock, 1840); modFile.close(); infile.close(); cout &lt;&lt; endl; return 0; } </code></pre> <p>Any help would be greatly appreciated, I hope there is some simple way to do this. </p> <p>Solved! thanks all of you very much. My day has been made!(well morning, its 4am)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload