我正在尝试将 a 转换const unsigned char*
为char*
并制作副本。我尝试了以下代码的几种变体,但通常会出现内存异常。此函数驻留在用 C 编写的应用程序中。
下面的函数是我想要创建的
//global variable
char* copiedValue;
void convertUnsignedChar(const unsigned char* message){
copiedValue = malloc(sizeof(message));
(void)memcpy(copiedValue, message, sizeof(message));
}