Given your description, you have the following 5 bytes:
1, 0, 2, 0, 0
You are somehow converting that to hex, which creates two-digits per byte:
"01 00 02 00 00"
But this is just a textual representation of the previous bytes. It is equivalent to all of these:
"0100020000"
"0x0100020000"
"4,295,098,368" (in decimal)
"040000400000" (in octal)
And the one you appear to want: "100020000"
Just like "1.00" is equivalent to "1.0", "01" is equivalent to "1".
If your goal is to get a string of all the bytes as two-digit strings, except the first, which should only have as many digits as required, then here is an example of that:
int bytes[5] = {1, 0, 2, 0, 0};
NSString *str = [NSString stringWithFormat:@"%x%02x%02x%02x%02x", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4]];
You could use a loop and append these if the numbre of bytes is unknown. Start with %x
and then use %02x
for all the subsequent.