我不明白为什么第二个结构有2个标签person和person_create。第二个结构如何返回一个指针。
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;
};
答案 0 :(得分:1)
没有第二个结构。它是一个返回struct Person
的函数,其名称为Person_create
。
答案 1 :(得分:1)
struct Person *Person_create(char *name,int age,int height,int weight)
阅读此行
Person_create
是函数名,此函数返回指向
结构的指针struct Person *