Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Writing hexadecimal to files
Writing hexadecimal to files [message #32517] Mon, 23 May 2011 14:07 Go to previous message
tjerk is currently offline  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:

str += "\x00";


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!
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: dll example errors when trying
Next Topic: How to reference value of an item on a layout?
Goto Forum:
  


Current Time: Thu May 09 00:11:20 CEST 2024

Total time taken to generate the page: 0.01679 seconds