Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing to bytes in a file

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi there

I'm a Visual C++ newbie and i want to read and write bytes from a file @ specified offsets. Simply how do I do this?

I currently use the following code, but it doesn't let me choose the offset of where I write to, only the value and number of bytes I patch. Please help!!!

==============================================

ofstream path("c:\\windows\\desktop\\debug.dat");
;
char *value_of_patch = "ffff";
int number_of_bytes = 10;

int setmode(int mode = filebuf::binary);
path.setmode(filebuf::binary);

path.write(value_of_patch, number_of_bytes);


================================================

Best regards,
Richard Edwards
 
you should

#inlcude<fstream>
using namespace std;
int main()
{
//put your code here
return 0;
}
John Fill
1c.bmp


ivfmd@mail.md
 
dont forget to open the fstream with ios::bin

fstream output(&quot;output.txt&quot;,ios::bin) so you dont get the extra endline characters and such.

matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top