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.

非4字节对齐地址的数据访问



老师您好!

我在C6701中需要对用一个unsigned int型指针指向一个非4字节对齐的地址进行操作,但是这回造成取数据错误,请问如何解决:

如:内存地址0x1000开始的数据为11, 22, 33, 44, 55, 66, 77, 88, 99,,,,,unsigned int *ptr=(unsigned int*)0x1002,则*ptr 输出0x44332211,实际上我需要0x66554433。

由于我的数据是从外部接收的数据,无法对其对齐方式进行要求,想请教一下老师有没有什么C编译指令可以让结果正确的,我的程序里很多地方都要这样访问,无法一一修改。