Home » Community » Newbie corner » Writing hexadecimal to files
Writing hexadecimal to files [message #32517] |
Mon, 23 May 2011 14:07  |
tjerk
Messages: 9 Registered: September 2009
|
Promising Member |
|
|
For a small utility I wanted to be able to write out hexadecimal values to a file. I can not change that file format (it's a config for a program I have no control over). I have deciphered the file so now I know which positions can be changed to what and I wanted to write a small utility that writes out a new .cfg file with different options selected.
I tried to do this by just making a String like so:
String myFile = "C:\\file.cfg";
String str = "\x05\x40\x03\x02\x01"; //just some test entries
SaveFile(myFile, str);
This works fine as long as I don't try to use:
This will terminate everything after. But I still need to write out that bit to fill up the spaces in the file that are not used. So ideally I should be able to make a string like this:
String str = "\x05\x00\x00\x00\x40\x00\x00\x00\x03\x02\x01";
But this does not work. The file only gets written up to the first occurrence of "\x00".
Am I going about it the wrong way? It was the only way I could think of with my limited programming knowledge and would appreciate a nudge into the right direction. Thanks in advance!
|
|
|
Goto Forum:
Current Time: Mon Apr 28 11:19:15 CEST 2025
Total time taken to generate the page: 0.00869 seconds
|