typedef struct {
int a;
int b;
}str;
int main()
{
void *p;
str *st;
st = (str*)malloc(sizeof(str));
st->a = 23;
st->b = 24;
p = st;
//使用void指针取值时需强制类型转换
printf("%d\n%d\n",((str*)p)->a, ((str*)p)->b);
free(st);
return 0
}
void指针
于 2024-03-03 11:29:42 首次发布