我想询问以下情况:
char *temp;
temp = malloc(10);
由于malloc
的返回类型是void*
,所以在分配给temp之前,指向malloc
返回的指针会被隐式转换为char*
类型吗?标准在这方面有什么规定吗?
如果我们的指针变量是某个结构体类型:
struct node *temp;
temp = (struct node *)malloc(sizeof(struct node));
如果我们为temp分配内存而不将其强制转换为struct node*
类型,它是否会自动转换为struct node*
类型,或者必须显式地将其转换为struct node*
类型?