这是我的代码:
nodebug void sendLogPacketS(char *func, char *msg)
{
char * log;
memset(log, 0, strlen(func) + strlen(msg) + 1);
strcpy(log, func);
strcat(log, ": ");
strcat(log, msg);
sendUDPLogPacket(log, strlen(log));
}
它应该采用两个字符串,将它们连接在一起,然后将新字符串及其长度传递给不同的函数。我使用的是 Dynamic C 9.62,它不支持该malloc
功能,所以我使用 memset 代替。
问题是当我 printf 的值log
之前它被传递给它时sendUDPLogPacket
,它包含垃圾DynamiCUniversal Rabbit BIOS Version 9.50\?^>j
。任何人都知道为什么这不起作用?