DWORD to bytes using bitwise shift operators

Posted by Dave18 on Stack Overflow See other posts from Stack Overflow or by Dave18
Published on 2010-04-22T17:52:16Z Indexed on 2010/04/22 17:53 UTC
Read the original article Hit count: 131

Filed under:

I can't get it to work correctly.

#include <windows.h>

int main()
{
    DWORD i  = 6521;

    BYTE first = i >> 32;
    BYTE second = i >> 24;
    BYTE third = i >> 16;
    BYTE fourth = i >> 8;

    i = (((DWORD)fourth) << 24) | (((DWORD)third) << 16) | (((DWORD)second) << 8) | first;
}

© Stack Overflow or respective owner

Related posts about c++