gpt4 book ai didi

c - 练习 16 中带指针的函数 艰难地学习 c

转载 作者:太空宇宙 更新时间:2023-11-04 07:16:46 24 4
gpt4 key购买 nike

<分区>

我对 learn C the hard way 的前 16 有疑问.

代码开头有一个函数定义:

struct Person {
char *name;
int age;
int height;
int weight;
};

struct Person *Person_create(char *name, int age, int height, int weight)
{
struct Person *who = malloc(sizeof(struct Person));
assert(who != NULL);

who->name = strdup(name);
who->age = age;
who->height = height;
who->weight = weight;

return who;
}

函数写成指针是什么原因? *人_创造?我真的很难理解指针的整个概念以及何时应该使用它们。谁能帮帮我?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com