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我见过类似的问题,但是我想我找不到那个。 你怎么说有类似的问题? 还是我需要这么做?