标签: c pointers malloc structure
当我使用malloc函数为C中的结构分配内存时,为什么我不必抛出函数,因为它的返回类型是void *而不是我想要的结构? 那么为什么呢:
Str *str = malloc(sizeof(Str));
而不是这个:
Str *str = (Str*)malloc(sizeof(Str));