什么是标记结构,它们与普通结构有什么不同?

时间:2015-01-08 11:53:58

标签: c

我不明白为什么第二个结构有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;
};

2 个答案:

答案 0 :(得分:1)

没有第二个结构。它是一个返回struct Person的函数,其名称为Person_create

答案 1 :(得分:1)

struct Person *Person_create(char *name,int age,int height,int weight)

阅读此行

Person_create 

是函数名,此函数返回指向

结构的指针
struct Person *