一则经典的问题:
//为了突出程序主要目的,忽略了malloc()分配是否成功检查与free()相关逻辑 //这是第一段代码 struct test { int num; }; void change_value(struct test *out) { struct test *in = (struct test *)malloc(sizeof(struct test)); in->num = 100; out = in; printf("in num:%d\n",out->num); } int main() { struct test *out = (struct test *)malloc(sizeof(struct test)); out->num = 0; change_value(out); printf("out num:%d\n",out->num); return 0; }