我想问一下以下 case :
char *temp;
temp = malloc(10);
由于malloc
的返回类型是void*
,malloc
返回的指针在分配给temp之前是否会隐式转换为char*
类型?标准对此有何规定?
如果我们的指针变量是某种 struct 类型,例如:
struct node *temp;
temp = (struct node *)malloc(sizeof(struct node));
如果我们将内存分配给Temp而不将其强制转换为struct node*
类型,它将被隐式强制转换为struct node*
类型还是有必要显式强制转换为struct node*
类型?