[Tutor] Search for hex data in file

Alan Gauld alan.gauld at btinternet.com
Mon May 25 09:22:44 CEST 2009


"xbmuncher" <xboxmuncher at gmail.com> wrote

> search through a file for a hex value and gets its byte offset in the 
> file.
> This hex value (that I'm looking for in the file) is of course a hex
> representation of the binary data and its 8 bytes long.

Can you give an example of your input data and what you expect
the return value to look like?

When you say it is a hex representation of binary data do you
mean something like:


"Here is some text with a hex number, 0xAB23C, embedded in it"

If so then you don;t need to convert to hex, you just need a string
search.

But I'm not clear exactly what kind of data you are dealing with.

> What do you guys recommend? I want to search the file for certain hex 
> value
> and get the byte offset within the file.

It might help if you posted some code too. And tell us what
happens when you run it, and why that was not what you wanted to happen...


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/ 




More information about the Tutor mailing list