这问题困惑了一段时间

- #include
-
- typedef unsigned char u8;
- typedef unsigned short u16;
- typedef unsigned int u32;
- int main()
- {
- u32 TT = 0x1111253C;
- u16 *temp1=(u16 *)(&TT);
- printf("-----------u32强转u16----------------\r\n");
- printf(" \r\n");
- printf("TT的地址 :%x\r\n", &TT);
- printf("TT的值 :%x\r\n", TT);
- printf(" \r\n");
-
- printf("temp1的地址 :%x\r\n", temp1);
- printf("temp1的值 :%x\r\n", *temp1);
- printf(" \r\n");
-
- temp1+=1;
- printf("temp1+1的地址 :%x\r\n", temp1);
- printf("temp1+1的值 :%x\r\n", *temp1);
- printf(" \r\n");
- printf("-----------u16强转u8----------------\r\n");
- printf(" \r\n");
- u16 TD = 0x253C;
- u8* temp = (u8*)(&TD);
- printf("TD的地址 :%x\r\n", &TD);
- printf("TD的值 :%x\r\n", TD);
- printf(" \r\n");
-
- printf("temp的地址 :%x\r\n", temp);
- printf("temp的值 :%x\r\n", *temp);
- printf(" \r\n");
-
- temp+=1;
- printf("temp+1的地址 :%x\r\n", temp);
- printf("temp+1的值 :%x\r\n", *temp);
-
- }