This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

请教C6748中内存对齐问题



您好:

我用的是CCS5.5,软件仿真测试环境。编写如下代码

unsigned char a[6];

unsigned short b;

void main()

{a[0]=0x08;

a[1]=0x00;

b=*((unsigned short*)(&a[0]));

}

结果b为8;

unsigned char a[6];

unsigned short b;

void main()

{a[1]=0x08;

a[2]=0x00;

b=*((unsigned short*)(&a[1]));

}

结果为2048。。

最后一句b=*((unsigned short*)(&a[n]));

其中的n为0 2 4的时候,结果是8

n为1 3 的时候,结果不是8.请问为什么,万分感谢!!