阅读 68

int转换为char,c语言字符串强制转换为int

有实现对EEPROM写入的API。 以下是关于C的uint8和char之间转换的声明

cyb le _ API _ result _ tcy ble _ store appdata (uint8* src buff,const uint8 destAddr[],uint32 buffLen,uint8isforcewritewrited

工作正常时,我调用此函数,发送数组参数声明为uint8型srcBuff。

问题是需要发送char数组指针。 虽然char已经认为是uint8,但是如果发送的是char数组指针而不是uint8,编译器会发出警告。 为什么我不能用char而不是uint8? 调用此函数的两个示例如下:

staticconstuint 8数据堆栈_ rom [ dedicatedromsize ]={0};

uint8 Container_ID[10];

char Prefix[10];

//callthefunctionwithcontainer _ idwhichasbeendeclaredasuint8. this is working。

cyb le _ store appdata (container _ id,datastack_ROM,10,0 );

//callthefunctionwithprefixwhichasbeendeclaredaschar.thisisnotworking。

cyble_storeappdata(prefix,datastack_ROM,10,0 );

接下来是第二个电话警告:

passing char [ 10 ] toparameteroftype ' uint8* ' convertsbetweenpointerstointegertypeswithdifferentsign。

char和uint8一样吗?

1

错误信息的重要内容是有关“不同符号”的部分。 这意味着你的" char "类型为" signed "," uint8"为" unsigned "。 这可能不是什么大问题,所以应该只能投影指针。 ' cyble_storeappdata((uint8* ) Prefix,) )

0

这似乎违反了限制。 请注意http://堆栈概述。 com/questions/30535814/pass-unsigned-char-pointer-to-atoi-without-cast

0

@GiorgiMoniava我见过类似的问题,但是我想我找不到那个。 你怎么说有类似的问题? 还是我需要这么做?


文章分类
代码人生
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐