【发布时间】:2013-06-13 15:05:40
【问题描述】:
给定内存分配:
struct typeA *p = malloc(sizeof(struct typeA));
然后在某个地方,例如在一个函数中,有两个选择:
void func(void *q)
{
....
free(q);
}
void func(void *q)
{
....
struct typeA *pp = (struct typeA *)q;
free(pp);
}
两者都可以,还是只有第二个可以?为什么?
【问题讨论】: