如何以小端方式读取字节 [英] how to read bytes in little endian manner

查看:93
本文介绍了如何以小端方式读取字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用sprintf从hex文件'%02x'读取字节用于阅读

/////

I am using sprintf for reading bytes from hex file '%02x' is used for reading
/////

for(i=start;i>=end;i--)
    {
        sprintf(hexstr, "%02x",buffer[i]);
         strcat( dataArray,  hexstr);
    }




如果我调用此函数




if i call this function

getByteLittleEndian(offset+4,offset,buffer);



错误来自memmory curruption error





如果我打电话


error comes memmory curruption error


if i call

getByteLittleEndian(offset+2,offset,buffer);



否错误,只有差异为2才有效,否则会出现错误,如何解决这个问题


no error,it's only working if the difference is 2 otherwise error comes how to solve this

推荐答案

这篇关于如何以小端方式读取字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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