-1

I'm trying to understand what an offset in a hex dump is. In particular, what purpose does an offset serve? I have googled many times but not found anything.

  • 3
    have you done ANY [research](http://brendanzagaeski.appspot.com/0006.html)? – jbutler483 Nov 11 '14 at 17:31
  • 1
    http://en.wikipedia.org/wiki/Offset_%28computer_science%29 – deviantfan Nov 11 '14 at 17:35
  • 1
    And http://stackoverflow.com/questions/141262/can-someone-explain-hex-offsets-to-me – deviantfan Nov 11 '14 at 17:36
  • *Offset* is how far something is from something else, generally. In a binary file, offsets are used to indicate where something else is in the file relative to a certain point in terms of number of bytes. Sometimes the offset represents how far from where the offset itself is stored, or it might represent offset from the beginning of the file, or from the end of the header, etc. All depends upon the file. – lurker Nov 11 '14 at 17:39
  • As a somewhat more concrete example - the offset of the first byte in a file is zero, the offset of the next byte is 1, and the next byte is at offset 2, etc... – twalberg Nov 11 '14 at 17:50
  • @lurker so suppose I have a pointer p of type uint_8* and an offset stored in an uint_8 variable, y, then to get the content stored in the address at that offset, can I use *(p + y)? – François Mizuta Nov 11 '14 at 17:52
  • 1
    Yes, *if* the offset stored is documented as an offset for the pointer `p`. But I have no idea where you got `p` from, or how it relates to the offset you're describing. – lurker Nov 11 '14 at 18:00

1 Answers1

0

The offset describes where something is in the file. You can obtain and jump to offsets in code using lseek(2) or fseek(3), depending on which I/O system you're using.

Kevin
  • 28,963
  • 9
  • 62
  • 81
  • Although it is hard to see what OP is asking, I don't think it has anything to do with seeking in files. – pmr Nov 11 '14 at 17:57
  • @pmr, It *could* involve seeking in files, but not necessarily. – lurker Nov 11 '14 at 18:00
  • @pmr: I assumed OP had a hex dump file on their computer somewhere and wanted to parse it (though perhaps "parse" is not precisely the correct term). – Kevin Nov 11 '14 at 18:35