我正在检查不需要显式地转换malloc调用结果的代码,但每当我尝试这样做时,编译器都会抛出错误.
即
char *somevar; somevar = malloc(sizeof(char) * n); //error somevar = (char *)malloc(sizeof(char) * n); // ok
c malloc casting compiler-errors
c ×1
casting ×1
compiler-errors ×1
malloc ×1