我有一个四字节的DWORD,我需要分成四个不同的字符。我以为我知道如何做到这一点,但每次都得到奇怪的数字。这里是我的代码:C++打破DWORD为字符
// The color memory
int32 col = color_mem[i];
// The four destination characters
char r, g, b, a;
// Copy them in advancing by one byte every time
memcpy(&r, &col, 1);
memcpy(&g, &col + 1, 1);
memcpy(&b, &col + 2, 1);
memcpy(&a, &col + 3, 1);
什么是color_mem的类型? – ryanbwork 2012-08-09 22:52:11