UINT16值看起来是“向后”打印时 [英] UINT16 value appears to be "backwards" when printing

查看:110
本文介绍了UINT16值看起来是“向后”打印时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UINT8指针mArray,它通过*(UINT16 *)转换分配信息。 EG:

I have a UINT8 pointer mArray, which is being assigned information via a *(UINT16 *) casting. EG:

int offset = someValue;
UINT16 mUINT16 = 0xAAFF
*(UINT16 *)&mArray[offset] = mUINT16;

for(int i = 0; i < mArrayLength; i++)
{
    printf("%02X",*(mArray + i));
}

output:   ... FF AA ...
expected: ... AA FF ...

当到达偏移量时,我希望打印的值是AA FF,但打印的值是FF AA,对于我的生活我不知道为什么。

The value I am expecting to be printed when it reaches offset is to be AA FF, but the value that is printed is FF AA, and for the life of me I can't figure out why.

推荐答案

您正在使用小端机。

这篇关于UINT16值看起来是“向后”打印时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆