有一个程序看不太懂
int main(){
unsigned int result = 0x0000;
unsigned char a=0x12;
unsigned char b=0x34;
((unsigned char *)&result)[0]=a;// unsigned int 类型强制转换成unsigned char指针
printf("result=%d\n",result);
printf("&reslult=0x%x\n",&result);//0x12
((unsigned char *)&result)[1]=b;
printf("result= 0x%x\n\n",result); //0x3412
system("pause");
return 0;
}
为什么result的最终输出结果为0x3412,这个程序的功能貌似是将两个字节数据重组为字数据, ((unsigned char *)&result)[0]=a有什么作用?麻烦哪位明白的帮我看一下啊
[此贴子已经被作者于2007-9-15 17:12:11编辑过]