运行结果怎么是266?低位低地址高位高地址怎么算?

#include<stdio.h>union{ int i;char x[2]; }a;void main(){ a.x[0]=10;a.x[1]=1; printf("%d",a.i);

交互式爱情
浏览 245回答 1
1回答

HUX布斯

#include<stdio.h>union{ int i;char x[2]; }a;void main(){ a.x[0]=10;a.x[1]=1;printf("%d",a.i);存储的时候是“低位在前”,a[0]是00001010,a[1]是00000001输出的i是将二个字节作为一个整数看,即是x[1]x[0]也就是00000001 00001010即 256+8+2=266。
打开App,查看更多内容
随时随地看视频慕课网APP