Before you can decide, or we can help you decide, which format specifier is the correct one to use, you will need to know how the information you are trying to unpack was packed.
For example, you mention an integer. An integer could be
- An 8-bit integer (byte),
- signed (-128 .. +127)
- unsigned (0 .. 255)
- A 16-bit integer (2 bytes/1 word)
- Signed (-32768 .. 32767 )
- Unsigned (0 .. 65535)
- A 32-bit integer (4 bytes/2 words/dword/long)
- Signed (-2147483648 .. 2147483647)
- Unsigned (0 .. 4294967295)
- A 64-bit integer (8 bytes/4 words/quadword/long long (etc!))
....
There are other formats but these are the most common.
Add to this, the possibility that some machines pack binary values into words in different (byte) orders. So called litte-endian and big-endian and with the exception of 1) above, you can double each of those possibilities, which is why pack/unpack have so many format specifiers for "integers": N n V v S s C c.
Which you need to use could be any of these, but as a guess, s, n, & v seem the most likely candidates. H seems the least likely.
In other words. You need to supply more information:)
Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!
|