#include <stdio.h>
#include <stdlib.h>
int main() {
void *malloc(size_t size);
char *ptr, *retval;
ptr = (char *)calloc(10, sizeof(char));
if (ptr == NULL)
printf("calloc failed\n");
else
printf("calloc successful\n");
retval = realloc(ptr, 5);
if (retval == NULL)
printf("realloc failed\n");
else
printf("realloc successful\n");
free(ptr);
free(retval);
}
这是我的代码,错误出现在第 14 行,它说
从“void*”到“char*”的无效转换