获得ptr所拥有的价值 [英] getting the value of what the ptr holds

查看:90
本文介绍了获得ptr所拥有的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if(tlv_tag_compare(tags.pTagID,\ x9F \ x91 \ x8B \ x15))

{



uint8 * ptr = tags.pTagID;

uint8 ch [4];

uint8 k = 0;

for(k = 0; k <= 3; k ++)

{

ch [k] = * ptr;

++ ptr;

}

uint8 temp [4];

sprintf(temp,%02x%02x%02x%02x,ch [0],ch [1],ch [2],ch [3]);



im尝试检查pTagID的值,我得到的是9F 91 8B 15

我的临时身份不同





谁能告诉我什么是不正确的?



pTag IS是一个uint8 const *

if (tlv_tag_compare(tags.pTagID, "\x9F\x91\x8B\x15"))
{

uint8 *ptr = tags.pTagID;
uint8 ch[4];
uint8 k=0;
for(k=0; k<=3;k++)
{
ch[k]=*ptr;
++ptr;
}
uint8 temp[4];
sprintf(temp,"%02x%02x%02x%02x",ch[0],ch[1],ch[2],ch[3]);

i m trying to examine the value of pTagID and I shoudl be getting 9F 91 8B 15
what i m getting in temp id different


can anyone tell me what is not correct?

pTag IS is a uint8 const*

推荐答案

为什么要打扰转换? * printf系列包括用于显示指针的转换。 %p

查看您的文档。大多数实现都会将其打印为地址大小的十六进制数。
Why bother with that conversion? The *printf family include a conversion meant for displaying pointers. %p
Check your documentation. Most implementations will print it as an address-size hex number.


这篇关于获得ptr所拥有的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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