uint32 unCompressLength = 0; memcpy(&unCompressLength, md5p + LIVE_DATA_HEADER_LEN_OFFSET, BUFLEN__); char src[unCompressLength] = {0}; 报错error: variable-sized object may not be initialized char src[unCompressLength] = {0};,给出改动较小的解决方案
时间: 2024-02-25 12:58:31 浏览: 70
a-example-of-MD5.rar_vc6 md5
可以将数组的初始化放在赋值操作之后,如下所示:
```
uint32 unCompressLength = 0;
memcpy(&unCompressLength, md5p + LIVE_DATA_HEADER_LEN_OFFSET, BUFLEN__);
char src[unCompressLength];
memset(src, 0, unCompressLength);
```
这里使用了`memset`函数来将数组初始化为0。由于`unCompressLength`是一个变量,所以无法在定义数组时进行初始化。
阅读全文