Link to home
Start Free TrialLog in
Avatar of CalTree
CalTree

asked on

get specific byte from unsigned long long

I have an unsigned long long k (64 bits / 8 bytes).
If we number the bytes in k 0 - 7, with byte 0 being on the rightmost end of k, does anyone know of a way to get a specific byte out? For example, byte 3?
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Exceter
Exceter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> 0 being on the rightmost end of k,

Ah,

printf("%2x",trans.s[7-0]); // First byte moving right to left
printf("%2x",trans.s[7-1]); // Second byte
printf("%2x",trans.s[7-2]); // Third byte

etc...

Exceter