alij said:
Given the following statement:
sscanf(src, "hh02x", &dest);
The part I don't understrand is, whats the 'hh' for? I know %h is for
hexadecimal extraction (why two h?). Also, whats the use of '02'?
No, I'm afraid you don't know what the 'h' is for. It doesn't mean
hexadecimal; that's what the 'x' means.
Since there's no '%' character in the format string, it doesn't
actually read anything. This illustrates why you should
copy-and-paste your exact code. By re-typing it, you've managed to
lose the most important part of it.
Probably the actual statement is:
sscanf(src, "%hh02x", &dest);
and presumably dest is declared to be of type unsigned char.
You should read the documentation for the sscanf function. If your
system doesn't provide it (try "man sscanf" if you're on a Unix-like
system), try Google.
"%x" specifies hexaecimal input. The "02" in front of it specifies
the maximum field width (I'm not sure whether the leading "0" is
meaningful). The "hh" says the corresponding argument is a pointer to
unsigned char rather than a pointer to unsigned int. (With a single
"h", it would be a pointer to unsigned short.)
The 'h' was probably chosen because it's the first letter of the word
"half", but that's just a mnemonic, not the actual meaning, since a
short isn't necessarily have the size of an int, and a char isn't
necessarily have the size of a short.
Read The Fine Manual.