指針強制轉換

#include <stdio.h> #include <stdlib.h> #include <string.h>

int main() { unsigned char a[8] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x44, 0x44, 0x43}; unsigned int *p = (unsigned int*)a; printf("0x%x\n", *(p + 1)); printf("0x%x\n", *(unsigned char*)(p + 1)); return 0; }


在小端模式下,輸出爲:spa

0x43444444
0x44

在大端模式下,輸出爲:code

0x112233
0x33
相關文章
相關標籤/搜索